Skip to content

Module dcm2bids.structure⚓︎

Participant class

None

View Source
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
# -*- coding: utf-8 -*-

"""Participant class"""

import logging

from os.path import join as opj

from future.utils import iteritems

from .utils import DEFAULT

from .version import __version__

class Participant(object):

    """ Class representing a participant

    Args:

        name (str): Label of your participant

        session (str): Optional label of a session

    """

    def __init__(self, name, session=DEFAULT.session):

        self._name = ""

        self._session = ""

        self.name = name

        self.session = session

    @property

    def name(self):

        """

        Returns:

            A string 'sub-<subject_label>'

        """

        return self._name

    @name.setter

    def name(self, name):

        """ Prepend 'sub-' if necessary"""

        if name.startswith("sub-"):

            self._name = name

        else:

            self._name = "sub-" + name

    @property

    def session(self):

        """

        Returns:

            A string 'ses-<session_label>'

        """

        return self._session

    @session.setter

    def session(self, session):

        """ Prepend 'ses-' if necessary"""

        if session.strip() == "":

            self._session = ""

        elif session.startswith("ses-"):

            self._session = session

        else:

            self._session = "ses-" + session

    @property

    def directory(self):

        """ The directory of the participant

        Returns:

            A path 'sub-<subject_label>' or

            'sub-<subject_label>/ses-<session_label>'

        """

        if self.hasSession():

            return opj(self.name, self.session)

        else:

            return self.name

    @property

    def prefix(self):

        """ The prefix to build filenames

        Returns:

            A string 'sub-<subject_label>' or

            'sub-<subject_label>_ses-<session_label>'

        """

        if self.hasSession():

            return self.name + "_" + self.session

        else:

            return self.name

    def hasSession(self):

        """ Check if a session is set

        Returns:

            Boolean

        """

        return self.session.strip() != DEFAULT.session

class Acquisition(object):

    """ Class representing an acquisition

    Args:

        participant (Participant): A participant object

        dataType (str): A functional group of MRI data (ex: func, anat ...)

        modalityLabel (str): The modality of the acquisition

                (ex: T1w, T2w, bold ...)

        customLabels (str): Optional labels (ex: task-rest)

        srcSidecar (Sidecar): Optional sidecar object

    """

    def __init__(

        self,

        participant,

        dataType,

        modalityLabel,

        indexSidecar=None,

        customLabels="",

        srcSidecar=None,

        sidecarChanges=None,

        intendedFor=None,

        IntendedFor=None,

        **kwargs

    ):

        self.logger = logging.getLogger(__name__)

        self._modalityLabel = ""

        self._customLabels = ""

        self._intendedFor = None

        self._indexSidecar = None

        self.participant = participant

        self.dataType = dataType

        self.modalityLabel = modalityLabel

        self.customLabels = customLabels

        self.srcSidecar = srcSidecar

        if sidecarChanges is None:

            self.sidecarChanges = {}

        else:

            self.sidecarChanges = sidecarChanges

        if intendedFor is None:

            self.intendedFor = IntendedFor

        else:

            self.intendedFor = intendedFor

        self.dstFile = ''

    def __eq__(self, other):

        return (

            self.dataType == other.dataType

            and self.participant.prefix == other.participant.prefix

            and self.suffix == other.suffix

        )

    @property

    def modalityLabel(self):

        """

        Returns:

            A string '_<modalityLabel>'

        """

        return self._modalityLabel

    @modalityLabel.setter

    def modalityLabel(self, modalityLabel):

        """ Prepend '_' if necessary"""

        self._modalityLabel = self.prepend(modalityLabel)

    @property

    def customLabels(self):

        """

        Returns:

            A string '_<customLabels>'

        """

        return self._customLabels

    @customLabels.setter

    def customLabels(self, customLabels):

        """ Prepend '_' if necessary"""

        self._customLabels = self.prepend(customLabels)

    @property

    def suffix(self):

        """ The suffix to build filenames

        Returns:

            A string '_<modalityLabel>' or '_<customLabels>_<modalityLabel>'

        """

        if self.customLabels.strip() == "":

            return self.modalityLabel

        else:

            return self.customLabels + self.modalityLabel

    @property

    def srcRoot(self):

        """

        Return:

            The sidecar source root to move

        """

        if self.srcSidecar:

            return self.srcSidecar.root

        else:

            return None

    @property

    def dstRoot(self):

        """

        Return:

            The destination root inside the BIDS structure

        """

        return opj(

            self.participant.directory,

            self.dataType,

            self.dstFile,

        )

    @property

    def dstIntendedFor(self):

        """

        Return:

            The destination root inside the BIDS structure for intendedFor

        """

        return opj(

            self.participant.session,

            self.dataType,

            self.dstFile,

        )

    def setDstFile(self):

        """

        Return:

            The destination filename formatted following the v1.7.0 BIDS entity key table

            https://bids-specification.readthedocs.io/en/v1.7.0/99-appendices/04-entity-table.html

        """

        current_name = self.participant.prefix + self.suffix

        new_name = ''

        current_dict = dict(x.split("-") for x in current_name.split("_") if len(x.split('-')) == 2)

        suffix_list = [x for x in current_name.split("_") if len(x.split('-')) == 1]

        for current_key in DEFAULT.entityTableKeys:

            if current_key in current_dict and new_name != '':

                new_name += f"_{current_key}-{current_dict[current_key]}"

            elif current_key in current_dict:

                new_name = f"{current_key}-{current_dict[current_key]}"

            current_dict.pop(current_key, None)

        for current_key in current_dict:

            new_name += f"_{current_key}-{current_dict[current_key]}"

        if current_dict:

            self.logger.warning("Entity \"{}\"".format(list(current_dict.keys())) +

                                " is not a valid BIDS entity.")

        new_name += f"_{'_'.join(suffix_list)}"  # Allow multiple single keys (without value)

        if len(suffix_list) != 1:

            self.logger.warning("There was more than one suffix found "

                                f"({suffix_list}). This is not BIDS "

                                "compliant. Make sure you know what "

                                "you are doing.")

        if current_name != new_name:

            self.logger.warning(

                f"""✅ Filename was reordered according to BIDS entity table order:

                from:   {current_name}

                to:     {new_name}""")

        self.dstFile = new_name

    @property

    def intendedFor(self):

        return self._intendedFor

    @intendedFor.setter

    def intendedFor(self, value):

        if isinstance(value, list):

            self._intendedFor = value

        else:

            self._intendedFor = [value]

    @property

    def indexSidecar(self):

        """

        Returns:

            A int '_<indexSidecar>'

        """

        return self._indexSidecar

    @indexSidecar.setter

    def indexSidecar(self, value):

        """

        Returns:

            A int '_<indexSidecar>'

        """

        self._indexSidecar = value

    def dstSidecarData(self, descriptions, intendedForList):

        """

        """

        data = self.srcSidecar.origData

        data["Dcm2bidsVersion"] = __version__

        # intendedFor key

        if self.intendedFor != [None]:

            intendedValue = []

            for index in self.intendedFor:

                intendedValue = intendedValue + intendedForList[index]

            if len(intendedValue) == 1:

                data["IntendedFor"] = intendedValue[0]

            else:

                data["IntendedFor"] = intendedValue

        # sidecarChanges

        for key, value in iteritems(self.sidecarChanges):

            data[key] = value

        return data

    @staticmethod

    def prepend(value, char="_"):

        """ Prepend `char` to `value` if necessary

        Args:

            value (str)

            char (str)

        """

        if value.strip() == "":

            return ""

        elif value.startswith(char):

            return value

        else:

            return char + value

Classes⚓︎

Acquisition⚓︎

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
class Acquisition(
    participant,
    dataType,
    modalityLabel,
    indexSidecar=None,
    customLabels='',
    srcSidecar=None,
    sidecarChanges=None,
    intendedFor=None,
    IntendedFor=None,
    **kwargs
)

Attributes⚓︎

Name Type Description Default
participant Participant A participant object None
dataType str A functional group of MRI data (ex: func, anat ...) None
modalityLabel str The modality of the acquisition
(ex: T1w, T2w, bold ...) None
customLabels str Optional labels (ex: task-rest) None
srcSidecar Sidecar Optional sidecar object None
View Source
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
class Acquisition(object):

    """ Class representing an acquisition

    Args:

        participant (Participant): A participant object

        dataType (str): A functional group of MRI data (ex: func, anat ...)

        modalityLabel (str): The modality of the acquisition

                (ex: T1w, T2w, bold ...)

        customLabels (str): Optional labels (ex: task-rest)

        srcSidecar (Sidecar): Optional sidecar object

    """

    def __init__(

        self,

        participant,

        dataType,

        modalityLabel,

        indexSidecar=None,

        customLabels="",

        srcSidecar=None,

        sidecarChanges=None,

        intendedFor=None,

        IntendedFor=None,

        **kwargs

    ):

        self.logger = logging.getLogger(__name__)

        self._modalityLabel = ""

        self._customLabels = ""

        self._intendedFor = None

        self._indexSidecar = None

        self.participant = participant

        self.dataType = dataType

        self.modalityLabel = modalityLabel

        self.customLabels = customLabels

        self.srcSidecar = srcSidecar

        if sidecarChanges is None:

            self.sidecarChanges = {}

        else:

            self.sidecarChanges = sidecarChanges

        if intendedFor is None:

            self.intendedFor = IntendedFor

        else:

            self.intendedFor = intendedFor

        self.dstFile = ''

    def __eq__(self, other):

        return (

            self.dataType == other.dataType

            and self.participant.prefix == other.participant.prefix

            and self.suffix == other.suffix

        )

    @property

    def modalityLabel(self):

        """

        Returns:

            A string '_<modalityLabel>'

        """

        return self._modalityLabel

    @modalityLabel.setter

    def modalityLabel(self, modalityLabel):

        """ Prepend '_' if necessary"""

        self._modalityLabel = self.prepend(modalityLabel)

    @property

    def customLabels(self):

        """

        Returns:

            A string '_<customLabels>'

        """

        return self._customLabels

    @customLabels.setter

    def customLabels(self, customLabels):

        """ Prepend '_' if necessary"""

        self._customLabels = self.prepend(customLabels)

    @property

    def suffix(self):

        """ The suffix to build filenames

        Returns:

            A string '_<modalityLabel>' or '_<customLabels>_<modalityLabel>'

        """

        if self.customLabels.strip() == "":

            return self.modalityLabel

        else:

            return self.customLabels + self.modalityLabel

    @property

    def srcRoot(self):

        """

        Return:

            The sidecar source root to move

        """

        if self.srcSidecar:

            return self.srcSidecar.root

        else:

            return None

    @property

    def dstRoot(self):

        """

        Return:

            The destination root inside the BIDS structure

        """

        return opj(

            self.participant.directory,

            self.dataType,

            self.dstFile,

        )

    @property

    def dstIntendedFor(self):

        """

        Return:

            The destination root inside the BIDS structure for intendedFor

        """

        return opj(

            self.participant.session,

            self.dataType,

            self.dstFile,

        )

    def setDstFile(self):

        """

        Return:

            The destination filename formatted following the v1.7.0 BIDS entity key table

            https://bids-specification.readthedocs.io/en/v1.7.0/99-appendices/04-entity-table.html

        """

        current_name = self.participant.prefix + self.suffix

        new_name = ''

        current_dict = dict(x.split("-") for x in current_name.split("_") if len(x.split('-')) == 2)

        suffix_list = [x for x in current_name.split("_") if len(x.split('-')) == 1]

        for current_key in DEFAULT.entityTableKeys:

            if current_key in current_dict and new_name != '':

                new_name += f"_{current_key}-{current_dict[current_key]}"

            elif current_key in current_dict:

                new_name = f"{current_key}-{current_dict[current_key]}"

            current_dict.pop(current_key, None)

        for current_key in current_dict:

            new_name += f"_{current_key}-{current_dict[current_key]}"

        if current_dict:

            self.logger.warning("Entity \"{}\"".format(list(current_dict.keys())) +

                                " is not a valid BIDS entity.")

        new_name += f"_{'_'.join(suffix_list)}"  # Allow multiple single keys (without value)

        if len(suffix_list) != 1:

            self.logger.warning("There was more than one suffix found "

                                f"({suffix_list}). This is not BIDS "

                                "compliant. Make sure you know what "

                                "you are doing.")

        if current_name != new_name:

            self.logger.warning(

                f"""✅ Filename was reordered according to BIDS entity table order:

                from:   {current_name}

                to:     {new_name}""")

        self.dstFile = new_name

    @property

    def intendedFor(self):

        return self._intendedFor

    @intendedFor.setter

    def intendedFor(self, value):

        if isinstance(value, list):

            self._intendedFor = value

        else:

            self._intendedFor = [value]

    @property

    def indexSidecar(self):

        """

        Returns:

            A int '_<indexSidecar>'

        """

        return self._indexSidecar

    @indexSidecar.setter

    def indexSidecar(self, value):

        """

        Returns:

            A int '_<indexSidecar>'

        """

        self._indexSidecar = value

    def dstSidecarData(self, descriptions, intendedForList):

        """

        """

        data = self.srcSidecar.origData

        data["Dcm2bidsVersion"] = __version__

        # intendedFor key

        if self.intendedFor != [None]:

            intendedValue = []

            for index in self.intendedFor:

                intendedValue = intendedValue + intendedForList[index]

            if len(intendedValue) == 1:

                data["IntendedFor"] = intendedValue[0]

            else:

                data["IntendedFor"] = intendedValue

        # sidecarChanges

        for key, value in iteritems(self.sidecarChanges):

            data[key] = value

        return data

    @staticmethod

    def prepend(value, char="_"):

        """ Prepend `char` to `value` if necessary

        Args:

            value (str)

            char (str)

        """

        if value.strip() == "":

            return ""

        elif value.startswith(char):

            return value

        else:

            return char + value

Static methods⚓︎

prepend⚓︎

1
2
3
4
def prepend(
    value,
    char='_'
)

Prepend char to value if necessary

Args: value (str) char (str)

View Source
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
    @staticmethod

    def prepend(value, char="_"):

        """ Prepend `char` to `value` if necessary

        Args:

            value (str)

            char (str)

        """

        if value.strip() == "":

            return ""

        elif value.startswith(char):

            return value

        else:

            return char + value

Instance variables⚓︎

1
customLabels

Returns:

A string '_'

1
dstIntendedFor

Return:

The destination root inside the BIDS structure for intendedFor

1
dstRoot

Return:

The destination root inside the BIDS structure

1
indexSidecar

Returns:

A int '_'

1
intendedFor
1
modalityLabel

Returns:

A string '_'

1
srcRoot

Return:

The sidecar source root to move

1
suffix

The suffix to build filenames

Methods⚓︎

dstSidecarData⚓︎

1
2
3
4
5
def dstSidecarData(
    self,
    descriptions,
    intendedForList
)
View Source
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
    def dstSidecarData(self, descriptions, intendedForList):

        """

        """

        data = self.srcSidecar.origData

        data["Dcm2bidsVersion"] = __version__

        # intendedFor key

        if self.intendedFor != [None]:

            intendedValue = []

            for index in self.intendedFor:

                intendedValue = intendedValue + intendedForList[index]

            if len(intendedValue) == 1:

                data["IntendedFor"] = intendedValue[0]

            else:

                data["IntendedFor"] = intendedValue

        # sidecarChanges

        for key, value in iteritems(self.sidecarChanges):

            data[key] = value

        return data

setDstFile⚓︎

1
2
3
def setDstFile(
    self
)

Return:

The destination filename formatted following the v1.7.0 BIDS entity key table https://bids-specification.readthedocs.io/en/v1.7.0/99-appendices/04-entity-table.html

View Source
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
    def setDstFile(self):

        """

        Return:

            The destination filename formatted following the v1.7.0 BIDS entity key table

            https://bids-specification.readthedocs.io/en/v1.7.0/99-appendices/04-entity-table.html

        """

        current_name = self.participant.prefix + self.suffix

        new_name = ''

        current_dict = dict(x.split("-") for x in current_name.split("_") if len(x.split('-')) == 2)

        suffix_list = [x for x in current_name.split("_") if len(x.split('-')) == 1]

        for current_key in DEFAULT.entityTableKeys:

            if current_key in current_dict and new_name != '':

                new_name += f"_{current_key}-{current_dict[current_key]}"

            elif current_key in current_dict:

                new_name = f"{current_key}-{current_dict[current_key]}"

            current_dict.pop(current_key, None)

        for current_key in current_dict:

            new_name += f"_{current_key}-{current_dict[current_key]}"

        if current_dict:

            self.logger.warning("Entity \"{}\"".format(list(current_dict.keys())) +

                                " is not a valid BIDS entity.")

        new_name += f"_{'_'.join(suffix_list)}"  # Allow multiple single keys (without value)

        if len(suffix_list) != 1:

            self.logger.warning("There was more than one suffix found "

                                f"({suffix_list}). This is not BIDS "

                                "compliant. Make sure you know what "

                                "you are doing.")

        if current_name != new_name:

            self.logger.warning(

                f"""✅ Filename was reordered according to BIDS entity table order:

                from:   {current_name}

                to:     {new_name}""")

        self.dstFile = new_name

Participant⚓︎

1
2
3
4
class Participant(
    name,
    session=''
)

Attributes⚓︎

Name Type Description Default
name str Label of your participant None
session str Optional label of a session None
View Source
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
class Participant(object):

    """ Class representing a participant

    Args:

        name (str): Label of your participant

        session (str): Optional label of a session

    """

    def __init__(self, name, session=DEFAULT.session):

        self._name = ""

        self._session = ""

        self.name = name

        self.session = session

    @property

    def name(self):

        """

        Returns:

            A string 'sub-<subject_label>'

        """

        return self._name

    @name.setter

    def name(self, name):

        """ Prepend 'sub-' if necessary"""

        if name.startswith("sub-"):

            self._name = name

        else:

            self._name = "sub-" + name

    @property

    def session(self):

        """

        Returns:

            A string 'ses-<session_label>'

        """

        return self._session

    @session.setter

    def session(self, session):

        """ Prepend 'ses-' if necessary"""

        if session.strip() == "":

            self._session = ""

        elif session.startswith("ses-"):

            self._session = session

        else:

            self._session = "ses-" + session

    @property

    def directory(self):

        """ The directory of the participant

        Returns:

            A path 'sub-<subject_label>' or

            'sub-<subject_label>/ses-<session_label>'

        """

        if self.hasSession():

            return opj(self.name, self.session)

        else:

            return self.name

    @property

    def prefix(self):

        """ The prefix to build filenames

        Returns:

            A string 'sub-<subject_label>' or

            'sub-<subject_label>_ses-<session_label>'

        """

        if self.hasSession():

            return self.name + "_" + self.session

        else:

            return self.name

    def hasSession(self):

        """ Check if a session is set

        Returns:

            Boolean

        """

        return self.session.strip() != DEFAULT.session

Instance variables⚓︎

1
directory

The directory of the participant

1
name

Returns:

A string 'sub-'

1
prefix

The prefix to build filenames

1
session

Returns:

A string 'ses-'

Methods⚓︎

hasSession⚓︎

1
2
3
def hasSession(
    self
)

Check if a session is set

Returns:

Type Description
None Boolean
View Source
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
    def hasSession(self):

        """ Check if a session is set

        Returns:

            Boolean

        """

        return self.session.strip() != DEFAULT.session

Last update: 2022-06-17
Back to top