diff --git a/bidscoin/bids.py b/bidscoin/bids.py index 489120b7..11b1ed9f 100644 --- a/bidscoin/bids.py +++ b/bidscoin/bids.py @@ -314,7 +314,7 @@ def dynamicvalue(self, value, cleanup: bool=True, runtime: bool=False): return value -def unpack(sesfolder: Path, wildcard: str='', workfolder: Path='', _subprefix: str='') -> Tuple[Set[Path], bool]: +def unpack(sesfolder: Path, wildcard: str='', workfolder: Path='', _subprefix: Union[str,None]='') -> Tuple[Set[Path], bool]: """ Unpacks and sorts DICOM files in sourcefolder to a temporary folder if sourcefolder contains a DICOMDIR file or .tar.gz, .gz or .zip files diff --git a/bidscoin/bidscoiner.py b/bidscoin/bidscoiner.py index fd1a8204..de55efed 100755 --- a/bidscoin/bidscoiner.py +++ b/bidscoin/bidscoiner.py @@ -33,7 +33,7 @@ def bidscoiner(rawfolder: str, bidsfolder: str, subjects: list=(), force: bool=F :param bidsfolder: The name of the BIDS root folder :param subjects: List of selected subjects / participants (i.e. sub-# names / folders) to be processed (the sub-prefix can be removed). Otherwise, all subjects in the sourcefolder will be selected :param force: If True, subjects will be processed, regardless of existing folders in the bidsfolder. Otherwise, existing folders will be skipped - :param bidsmapfile: The name of the bidsmap YAML-file. If the bidsmap pathname is relative (i.e. no "/" in the name) then it is assumed to be located in bidsfolder/code/bidscoin + :param bidsmapfile: The name of the bidsmap YAML-file. If the bidsmap pathname is just the basename (i.e. no "/" in the name) then it is assumed to be located in bidsfolder/code/bidscoin :param cluster: Use the DRMAA library to submit the bidscoiner jobs to a high-performance compute (HPC) cluster :param nativespec: DRMAA native specifications for submitting bidscoiner jobs to the HPC cluster. See cli/_bidscoiner() for default :return: Nothing diff --git a/bidscoin/cli/_bidscoiner.py b/bidscoin/cli/_bidscoiner.py index fdb26831..a3a15bec 100755 --- a/bidscoin/cli/_bidscoiner.py +++ b/bidscoin/cli/_bidscoiner.py @@ -31,7 +31,7 @@ def get_parser(): parser.add_argument('sourcefolder', help='The study root folder containing the raw source data') parser.add_argument('bidsfolder', help='The destination / output folder with the bids data') parser.add_argument('-p','--participant_label', help='Space separated list of selected sub-# names / folders to be processed (the sub-prefix can be removed). Otherwise all subjects in the sourcefolder will be selected', nargs='+') - parser.add_argument('-b','--bidsmap', help='The study bidsmap file with the mapping heuristics. If the bidsmap filename is relative (i.e. no "/" in the name) then it is assumed to be located in bidsfolder/code/bidscoin. Default: bidsmap.yaml', default='bidsmap.yaml') + parser.add_argument('-b','--bidsmap', help='The study bidsmap file with the mapping heuristics. If the bidsmap filename is just the basename (i.e. no "/" in the name) then it is assumed to be located in bidsfolder/code/bidscoin. Default: bidsmap.yaml', default='bidsmap.yaml') parser.add_argument('-f','--force', help='Process all subjects, regardless of existing subject folders in the bidsfolder. Otherwise these subject folders will be skipped', action='store_true') parser.add_argument('-c','--cluster', help='Use the DRMAA library to submit the bidscoiner jobs to a high-performance compute (HPC) cluster', action='store_true') parser.add_argument('-n','--nativespec', help='Opaque DRMAA argument with native specifications for submitting bidscoiner jobs to the HPC cluster. NB: Use quotes and include at least one space character to prevent overearly parsing (default: -l walltime=00:30:00,mem=4gb)', default='-l walltime=00:30:00,mem=4gb') diff --git a/bidscoin/cli/_bidseditor.py b/bidscoin/cli/_bidseditor.py index 26663a1a..ba066ba3 100755 --- a/bidscoin/cli/_bidseditor.py +++ b/bidscoin/cli/_bidseditor.py @@ -31,7 +31,7 @@ def get_parser() -> argparse.ArgumentParser: bidseditor myproject/bids -b my/custom/bidsmap.yaml""")) parser.add_argument('bidsfolder', help='The destination folder with the (future) bids data') - parser.add_argument('-b','--bidsmap', help='The study bidsmap file with the mapping heuristics. If the bidsmap filename is relative (i.e. no "/" in the name) then it is assumed to be located in bidsfolder/code/bidscoin. Default: bidsmap.yaml', default='bidsmap.yaml') - parser.add_argument('-t','--template', help=f'The template bidsmap file with the default heuristics (this could be provided by your institute). If the bidsmap filename is relative (i.e. no "/" in the name) then it is assumed to be located in bidsfolder/code/bidscoin. Default: {bidsmap_template.stem}', default=bidsmap_template) + parser.add_argument('-b','--bidsmap', help='The study bidsmap file with the mapping heuristics. If the bidsmap filename is just the basename (i.e. no "/" in the name) then it is assumed to be located in bidsfolder/code/bidscoin. Default: bidsmap.yaml', default='bidsmap.yaml') + parser.add_argument('-t','--template', help=f'The template bidsmap file with the default heuristics (this could be provided by your institute). If the bidsmap filename is just the basename (i.e. no "/" in the name) then it is assumed to be located in the bidscoin config folder. Default: {bidsmap_template.stem}', default=bidsmap_template) return parser diff --git a/bidscoin/cli/_bidsmapper.py b/bidscoin/cli/_bidsmapper.py index 2d55907d..ced17754 100755 --- a/bidscoin/cli/_bidsmapper.py +++ b/bidscoin/cli/_bidsmapper.py @@ -33,8 +33,8 @@ def get_parser() -> argparse.ArgumentParser: " bidsmapper myproject/raw myproject/bids -u '*.tar.gz' # Unzip tarball sourcefiles\n ") parser.add_argument('sourcefolder', help='The study root folder containing the raw source data folders') parser.add_argument('bidsfolder', help='The destination folder with the (future) bids data and the bidsfolder/code/bidscoin/bidsmap.yaml output file') - parser.add_argument('-b','--bidsmap', help="The study bidsmap file with the mapping heuristics. If the bidsmap filename is relative (i.e. no '/' in the name) then it is assumed to be located in bidsfolder/code/bidscoin. Default: bidsmap.yaml", default='bidsmap.yaml') - parser.add_argument('-t','--template', help=f"The bidsmap template file with the default heuristics (this could be provided by your institute). If the bidsmap filename is relative (i.e. no '/' in the name) then it is assumed to be located in bidsfolder/code/bidscoin. Default: {bidsmap_template.stem}", default=bidsmap_template) + parser.add_argument('-b','--bidsmap', help="The study bidsmap file with the mapping heuristics. If the bidsmap filename is just the basename (i.e. no '/' in the name) then it is assumed to be located in bidsfolder/code/bidscoin. Default: bidsmap.yaml", default='bidsmap.yaml') + parser.add_argument('-t','--template', help=f"The bidsmap template file with the default heuristics (this could be provided by your institute). If the bidsmap filename is just the basename (i.e. no '/' in the name) then it is assumed to be located in the bidscoin config folder. Default: {bidsmap_template.stem}", default=bidsmap_template) parser.add_argument('-p','--plugins', help='List of plugins to be used. Default: the plugin list of the study/template bidsmap)', nargs='+', default=[]) parser.add_argument('-n','--subprefix', help="The prefix common for all the source subject-folders (e.g. 'Pt' is the subprefix if subject folders are named 'Pt018', 'Pt019', ...). Use '*' when your subject folders do not have a prefix. Default: the value of the study/template bidsmap, e.g. 'sub-'") parser.add_argument('-m','--sesprefix', help="The prefix common for all the source session-folders (e.g. 'M_' is the subprefix if session folders are named 'M_pre', 'M_post', ..). Use '*' when your session folders do not have a prefix. Default: the value of the study/template bidsmap, e.g. 'ses-'") diff --git a/bidscoin/cli/_bidsparticipants.py b/bidscoin/cli/_bidsparticipants.py index 34d53ac6..e4decf60 100755 --- a/bidscoin/cli/_bidsparticipants.py +++ b/bidscoin/cli/_bidsparticipants.py @@ -26,6 +26,6 @@ def get_parser(): parser.add_argument('bidsfolder', help='The destination / output folder with the bids data') parser.add_argument('-k','--keys', help="Space separated list of the participants.tsv columns. Default: 'session_id' 'age' 'sex' 'size' 'weight'", nargs='+', default=['age', 'sex', 'size', 'weight']) # NB: session_id is default parser.add_argument('-d','--dryrun', help='Do not save anything, only print the participants info on screen', action='store_true') - parser.add_argument('-b','--bidsmap', help='The study bidsmap file with the mapping heuristics. If the bidsmap filename is relative (i.e. no "/" in the name) then it is assumed to be located in bidsfolder/code/bidscoin. Default: bidsmap.yaml', default='bidsmap.yaml') + parser.add_argument('-b','--bidsmap', help='The study bidsmap file with the mapping heuristics. If the bidsmap filename is just the basename (i.e. no "/" in the name) then it is assumed to be located in bidsfolder/code/bidscoin. Default: bidsmap.yaml', default='bidsmap.yaml') return parser diff --git a/bidscoin/utilities/bidsparticipants.py b/bidscoin/utilities/bidsparticipants.py index ab6c3a07..9691b231 100755 --- a/bidscoin/utilities/bidsparticipants.py +++ b/bidscoin/utilities/bidsparticipants.py @@ -59,7 +59,7 @@ def bidsparticipants(rawfolder: str, bidsfolder: str, keys: list, bidsmapfile: s :param rawfolder: The root folder-name of the sub/ses/data/file tree containing the source data files :param bidsfolder: The name of the BIDS root folder :param keys: The keys that are extracted from the source data when populating the participants.tsv file - :param bidsmapfile: The name of the bidsmap YAML-file. If the bidsmap pathname is relative (i.e. no "/" in the name) then it is assumed to be located in bidsfolder/code/bidscoin + :param bidsmapfile: The name of the bidsmap YAML-file. If the bidsmap pathname is just the basename (i.e. no "/" in the name) then it is assumed to be located in bidsfolder/code/bidscoin :param dryrun: Boolean to just display the participants info :return: Nothing """ diff --git a/bidscoin/utilities/dicomsort.py b/bidscoin/utilities/dicomsort.py index 1f07f709..c3af64e6 100755 --- a/bidscoin/utilities/dicomsort.py +++ b/bidscoin/utilities/dicomsort.py @@ -8,6 +8,7 @@ from pathlib import Path from typing import List, Set from importlib.util import find_spec +from typing import Union if find_spec('bidscoin') is None: import sys sys.path.append(str(Path(__file__).parents[2])) @@ -134,13 +135,13 @@ def sortsession(sessionfolder: Path, dicomfiles: List[Path], folderscheme: str, dicomfile.replace(newfilename) -def sortsessions(sourcefolder: Path, subprefix: str='', sesprefix: str='', folderscheme: str='{SeriesNumber:03d}-{SeriesDescription}', +def sortsessions(sourcefolder: Path, subprefix: Union[str,None]='', sesprefix: str='', folderscheme: str='{SeriesNumber:03d}-{SeriesDescription}', namescheme: str='', pattern: str=r'.*\.(IMA|dcm)$', recursive: bool=True, force: bool=False, dryrun: bool=False) -> Set[Path]: """ Wrapper around sortsession() to loop over subjects and sessions and map the session DICOM files :param sourcefolder: The root folder containing the source [sub/][ses/]dicomfiles or the DICOMDIR file - :param subprefix: The prefix for searching the sub folders in session. Use '' to sort DICOMDIR files directly in sourcefolder + :param subprefix: The prefix for searching the sub folders in session. Use '' to sort DICOMDIR files directly in sourcefolder (None will add DICOMDIR-based sub-/ses-folders :param sesprefix: The prefix for searching the ses folders in sub folder :param folderscheme: Optional naming scheme for the sorted (e.g. Series) subfolders. Follows the Python string formatting syntax with DICOM field names in curly bracers with an optional number of digits for numeric fields', default='{SeriesNumber:03d}-{SeriesDescription}' :param namescheme: Optional naming scheme for renaming the files. Follows the Python string formatting syntax with DICOM field names in curly bracers, e.g. {PatientName}_{SeriesNumber:03d}_{SeriesDescription}_{AcquisitionNumber:05d}_{InstanceNumber:05d}.IMA diff --git a/docs/utilities.rst b/docs/utilities.rst index 48a21bc3..e3a9addf 100644 --- a/docs/utilities.rst +++ b/docs/utilities.rst @@ -202,7 +202,7 @@ The bidsparticipants tool is useful for (re-)generating a participants.tsv file -d, --dryrun Do not save anything, only print the participants info on screen -b BIDSMAP, --bidsmap BIDSMAP The study bidsmap file with the mapping heuristics. If the bidsmap filename - is relative (i.e. no "/" in the name) then it is assumed to be located in + is just the basename (i.e. no "/" in the name) then it is assumed to be located in bidsfolder/code/bidscoin. Default: bidsmap.yaml examples: diff --git a/docs/workflow.rst b/docs/workflow.rst index a54240ff..e7ee6375 100644 --- a/docs/workflow.rst +++ b/docs/workflow.rst @@ -46,12 +46,12 @@ Step 1a: Running the bidsmapper -h, --help show this help message and exit -b BIDSMAP, --bidsmap BIDSMAP The study bidsmap file with the mapping heuristics. If the bidsmap filename - is relative (i.e. no '/' in the name) then it is assumed to be located in + is just the basename (i.e. no '/' in the name) then it is assumed to be located in bidsfolder/code/bidscoin. Default: bidsmap.yaml -t TEMPLATE, --template TEMPLATE The bidsmap template file with the default heuristics (this could be provided - by your institute). If the bidsmap filename is relative (i.e. no '/' in the - name) then it is assumed to be located in bidsfolder/code/bidscoin. Default: + by your institute). If the bidsmap filename is just the basename (i.e. no '/' in + the name) then it is assumed to be located in the bidscoin config folder. Default: bidsmap_dccn -p PLUGINS [PLUGINS ...], --plugins PLUGINS [PLUGINS ...] List of plugins to be used. Default: the plugin list of the study/template @@ -112,12 +112,12 @@ Step 1b: Running the bidseditor -h, --help show this help message and exit -b BIDSMAP, --bidsmap BIDSMAP The study bidsmap file with the mapping heuristics. If the bidsmap filename - is relative (i.e. no "/" in the name) then it is assumed to be located in + is just the basename (i.e. no "/" in the name) then it is assumed to be located in bidsfolder/code/bidscoin. Default: bidsmap.yaml -t TEMPLATE, --template TEMPLATE The template bidsmap file with the default heuristics (this could be provided - by your institute). If the bidsmap filename is relative (i.e. no "/" in the - name) then it is assumed to be located in bidsfolder/code/bidscoin. Default: + by your institute). If the bidsmap filename is just the basename (i.e. no "/" in + the name) then it is assumed to be located in the bidscoin config folder. Default: bidsmap_dccn examples: @@ -203,7 +203,7 @@ Step 2: Running the bidscoiner be selected -b BIDSMAP, --bidsmap BIDSMAP The study bidsmap file with the mapping heuristics. If the bidsmap filename - is relative (i.e. no "/" in the name) then it is assumed to be located in + is just the basename (i.e. no "/" in the name) then it is assumed to be located in bidsfolder/code/bidscoin. Default: bidsmap.yaml -f, --force Process all subjects, regardless of existing subject folders in the bidsfolder. Otherwise these subject folders will be skipped diff --git a/tests/test_bids.py b/tests/test_bids.py index 157a3852..e80fc199 100644 --- a/tests/test_bids.py +++ b/tests/test_bids.py @@ -92,7 +92,7 @@ def test_dynamicvalue(self, datasource): assert datasource.dynamicvalue(r'<(0010, 0010)>') == 'CompressedSamplesMR1' def test_unpack(dicomdir, tmp_path): - sessions, unpacked = bids.unpack(dicomdir.parent, '', tmp_path, None) + sessions, unpacked = bids.unpack(dicomdir.parent, '', tmp_path, None) # None -> simulate commandline usage of dicomsort() assert unpacked assert len(sessions) == 6 for session in sessions: @@ -124,32 +124,32 @@ def test_load_check_template(template): # Load a valid template bidsmap, _ = bids.load_bidsmap(template, checks=(False, False, False)) assert isinstance(bidsmap, dict) and bidsmap - assert bids.check_template(bidsmap) == True + assert bids.check_template(bidsmap) is True # Add an invalid data type bidsmap['DICOM']['foo'] = bidsmap['DICOM']['extra_data'] - assert bids.check_template(bidsmap) == False + assert bids.check_template(bidsmap) is False del bidsmap['DICOM']['foo'] # Remove a valid suffix (BIDS-entity) bidsmap['DICOM']['anat'].pop(-2) # NB: Assumes CT is the last item, MTR the second last - assert bids.check_template(bidsmap) == False + assert bids.check_template(bidsmap) is False def test_match_runvalue(): - assert bids.match_runvalue('my_pulse_sequence_name', '_name') == False - assert bids.match_runvalue('my_pulse_sequence_name', '^my.*name$') == True - assert bids.match_runvalue('T1_MPRage', '(?i).*(MPRAGE|T1w).*') == True - assert bids.match_runvalue('', None) == True - assert bids.match_runvalue(None, '') == True - assert bids.match_runvalue( [1, 2, 3], [1,2, 3]) == True - assert bids.match_runvalue( [1,2, 3], '[1, 2, 3]') == True - assert bids.match_runvalue( [1, 2, 3], r'\[1, 2, 3\]') == True - assert bids.match_runvalue( '[1, 2, 3]', '[1, 2, 3]') == True - assert bids.match_runvalue( '[1, 2, 3]', r'\[1, 2, 3\]') == True - assert bids.match_runvalue( '[1, 2, 3]', [1, 2, 3]) == True - assert bids.match_runvalue( '[1,2, 3]', [1,2, 3]) == False - assert bids.match_runvalue(r'\[1, 2, 3\]', [1, 2, 3]) == False + assert bids.match_runvalue('my_pulse_sequence_name', '_name') is False + assert bids.match_runvalue('my_pulse_sequence_name', '^my.*name$') is True + assert bids.match_runvalue('T1_MPRage', '(?i).*(MPRAGE|T1w).*') is True + assert bids.match_runvalue('', None) is True + assert bids.match_runvalue(None, '') is True + assert bids.match_runvalue( [1, 2, 3], [1,2, 3]) is True + assert bids.match_runvalue( [1,2, 3], '[1, 2, 3]') is True + assert bids.match_runvalue( [1, 2, 3], r'\[1, 2, 3\]') is True + assert bids.match_runvalue( '[1, 2, 3]', '[1, 2, 3]') is True + assert bids.match_runvalue( '[1, 2, 3]', r'\[1, 2, 3\]') is True + assert bids.match_runvalue( '[1, 2, 3]', [1, 2, 3]) is True + assert bids.match_runvalue( '[1,2, 3]', [1,2, 3]) is False + assert bids.match_runvalue(r'\[1, 2, 3\]', [1, 2, 3]) is False def test_load_bidsmap(study_bidsmap): @@ -184,29 +184,29 @@ def test_validate_bidsmap(study_bidsmap): # Load a BIDS-valid study bidsmap bidsmap, _ = bids.load_bidsmap(study_bidsmap) run = bidsmap['DICOM']['func'][0] - assert bids.validate_bidsmap(bidsmap) == True + assert bids.validate_bidsmap(bidsmap) is True # Validate the bids-keys run['bids']['flip'] = 'foo' # Add a false key - assert bids.validate_bidsmap(bidsmap) == False + assert bids.validate_bidsmap(bidsmap) is False del run['bids']['flip'] del run['bids']['task'] # Remove a required key - assert bids.validate_bidsmap(bidsmap) == False + assert bids.validate_bidsmap(bidsmap) is False run['bids']['task'] = 'foo' # Check bids-suffix run['bids']['suffix'] = 'T1w' # Set an invalid suffix - assert bids.validate_bidsmap(bidsmap) == False + assert bids.validate_bidsmap(bidsmap) is False run['bids']['suffix'] = 'bold' # Check bids-values run['bids']['task'] = '' # Remove a required value - assert bids.validate_bidsmap(bidsmap) == False + assert bids.validate_bidsmap(bidsmap) is False run['bids']['task'] = 'f##' # Add invalid characters (they are cleaned out) - assert bids.validate_bidsmap(bidsmap) == True + assert bids.validate_bidsmap(bidsmap) is True run['bids']['task'] = 'foo' run['bids']['run'] = 'a' # Add an invalid (non-numeric) index - assert bids.validate_bidsmap(bidsmap) == False + assert bids.validate_bidsmap(bidsmap) is False def test_check_bidsmap(study_bidsmap): @@ -228,7 +228,7 @@ def test_check_bidsmap(study_bidsmap): for each, check in zip(is_valid, checks): assert each in (None, True, False) if check: - assert each == True + assert each is True def test_check_run(study_bidsmap): @@ -272,14 +272,14 @@ def test_check_ignore(): bidsignore = ['mrs/', 'sub-*_foo.*', '*foo/sub-*_bar.*'] - assert bids.check_ignore('mrs', bidsignore) == True # Test default: datatype = 'dir' - assert bids.check_ignore('mrs', bidsignore, 'file') == False - assert bids.check_ignore('mrs/sub-01_foo.nii', bidsignore, 'dir') == False - assert bids.check_ignore('mrs/sub-01_bar.nii', bidsignore, 'file') == False - assert bids.check_ignore('foo/sub-01_bar.nii', bidsignore, 'file') == True - assert bids.check_ignore('bar/sub-01_bar.nii', bidsignore, 'file') == False - assert bids.check_ignore('bar/sub-01_foo.nii', bidsignore, 'file') == False - assert bids.check_ignore('sub-01_foo.nii', bidsignore, 'file') == True + assert bids.check_ignore('mrs', bidsignore) is True # Test default: datatype = 'dir' + assert bids.check_ignore('mrs', bidsignore, 'file') is False + assert bids.check_ignore('mrs/sub-01_foo.nii', bidsignore, 'dir') is False + assert bids.check_ignore('mrs/sub-01_bar.nii', bidsignore, 'file') is False + assert bids.check_ignore('foo/sub-01_bar.nii', bidsignore, 'file') is True + assert bids.check_ignore('bar/sub-01_bar.nii', bidsignore, 'file') is False + assert bids.check_ignore('bar/sub-01_foo.nii', bidsignore, 'file') is False + assert bids.check_ignore('sub-01_foo.nii', bidsignore, 'file') is True def test_find_run(study_bidsmap): @@ -336,7 +336,7 @@ def test_append_run(study_bidsmap): # Append the run elsewhere in the bidsmap bids.append_run(bidsmap, run) - assert Path(bidsmap['Foo']['Bar'][0]['provenance']) == Path(run['provenance']) + assert bidsmap['Foo']['Bar'][0]['provenance'] == run['provenance'] def test_update_bidsmap(study_bidsmap): @@ -350,8 +350,8 @@ def test_update_bidsmap(study_bidsmap): # Update the bidsmap bids.update_bidsmap(bidsmap, 'func', run) - assert Path(bidsmap['DICOM']['anat'][-1]['provenance']) == Path(run['provenance']) - assert Path(bidsmap['DICOM']['func'] [0]['provenance']) != Path(run['provenance']) + assert bidsmap['DICOM']['anat'][-1]['provenance'] == run['provenance'] + assert bidsmap['DICOM']['func'] [0]['provenance'] != run['provenance'] # Modify the last anat run-item and update the bidsmap run['bids']['foo'] = 'bar' @@ -368,17 +368,17 @@ def test_exist_run(study_bidsmap): run = copy.deepcopy(bidsmap['DICOM']['anat'][0]) # Find the run in the wrong data type - assert bids.exist_run(bidsmap, 'func', run) == False + assert bids.exist_run(bidsmap, 'func', run) is False # Find run with in the right data type and in all datatypes - assert bids.exist_run(bidsmap, 'anat', run) == True - assert bids.exist_run(bidsmap, '', run) == True + assert bids.exist_run(bidsmap, 'anat', run) is True + assert bids.exist_run(bidsmap, '', run) is True # Find the wrong run in all datatypes run['attributes']['ProtocolName'] = 'abcdefg' - assert bids.exist_run(bidsmap, '', run) == False + assert bids.exist_run(bidsmap, '', run) is False run['attributes']['ProtocolName'] = '' - assert bids.exist_run(bidsmap, '', run) == False + assert bids.exist_run(bidsmap, '', run) is False def test_increment_runindex__no_run1(tmp_path): diff --git a/tests/test_bidscoiner.py b/tests/test_bidscoiner.py index 91dfcd57..e3b36f0a 100644 --- a/tests/test_bidscoiner.py +++ b/tests/test_bidscoiner.py @@ -40,7 +40,7 @@ def test_bidscoiner(raw_dicomdir, bids_dicomdir, bidsmap_dicomdir): for (path, entry_key), citation in credits.citations.items(): if entry_key == '10.3389/fninf.2021.770608': assert path == 'bidscoin' - assert citation.cite_module == True + assert citation.cite_module is True assert citation.version == __version__ diff --git a/tests/test_utilities.py b/tests/test_utilities.py index 91b558e0..1477bb9e 100644 --- a/tests/test_utilities.py +++ b/tests/test_utilities.py @@ -12,9 +12,9 @@ def test_dicomsort(tmp_path): shutil.copytree(Path(get_testdata_file('DICOMDIR')).parent, tmp_path, dirs_exist_ok=True) session = sorted(dicomsort.sortsessions(tmp_path/'DICOMDIR', None, folderscheme='{SeriesNumber:04d}-{SeriesDescription}', namescheme='{SeriesNumber:02d}_{SeriesDescription}_{AcquisitionNumber}_{InstanceNumber}.IMA', force=True)) assert dicomsort.sortsessions(tmp_path/'DICOMDIR', None, folderscheme='{SeriesNumber:04d]-{SeriesDescription}') == set() # Invalid scheme -> clean return - assert dicomsort.validscheme('{foo:04d}-{123}') == True - assert dicomsort.validscheme('{foo:04d]-{bar}') == False - assert dicomsort.validscheme('{foo:04}-{bar}') == False + assert dicomsort.validscheme('{foo:04d}-{123}') is True + assert dicomsort.validscheme('{foo:04d]-{bar}') is False + assert dicomsort.validscheme('{foo:04}-{bar}') is False assert (tmp_path/'Doe^Peter').is_dir() # Subject (Patient): 98890234 -> Doe^Peter assert (tmp_path/'Doe^Archibald').is_dir() # 77654033 -> Doe^Archibald assert len(list((tmp_path/'Doe^Archibald').rglob('*'))) == 13 # 6 directories + 7 files