Skip to content

Commit 6a2ff66

Browse files
authored
Merge pull request Open-Minds-Lab#32 from sinhaharsh/main
Bugfixes for BidsDataset
2 parents 80b1049 + 1f6c034 commit 6a2ff66

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

MRdataset/bids.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from MRdataset import logger
66
from MRdataset.base import BaseDataset
7-
from MRdataset.config import VALID_BIDS_DATATYPES
7+
from MRdataset.config import VALID_BIDS_DATATYPES, SUPPORTED_BIDS_DATATYPES
88
from MRdataset.dicom_utils import is_bids_file
99
from MRdataset.utils import folders_with_min_files, valid_dirs, read_json
1010
from protocol import BidsImagingSequence
@@ -129,6 +129,13 @@ def _process(self, folder):
129129
name=name)
130130
if seq.is_valid():
131131
sequences.append(seq)
132+
else:
133+
if name not in SUPPORTED_BIDS_DATATYPES:
134+
logger.error(f'MRdataset primarily supports '
135+
f'{SUPPORTED_BIDS_DATATYPES}'
136+
f'It seems the parameters in '
137+
f'this sequence are invalid or '
138+
f'not supported yet. Skipping it.')
132139
return sequences
133140

134141
@staticmethod
@@ -138,7 +145,7 @@ def get_run_id(filename, last_id):
138145
Example filename : sub-01_ses-imagery01_task-imagery_run-01_bold.json
139146
"""
140147
# Regular expression pattern
141-
pattern = r'run-\d+'
148+
pattern = r'run-[^_]+'
142149
# Extracting substring using regex
143150
match = search(pattern, str(filename))
144151

MRdataset/config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
'pet'
3131
]
3232

33+
SUPPORTED_BIDS_DATATYPES = ['func', 'anat', 'dwi', 'fmap']
3334

34-
# Suppress duplicated warnings
3535

3636
class MRException(Exception):
3737
"""
@@ -59,7 +59,7 @@ def __init__(self):
5959
'--data_source. Got 0 DICOM/JSON files.')
6060

6161

62-
def configure_logger(log, output_dir, mode='w', level='WARNING'):
62+
def configure_logger(log, output_dir, mode='w', level='ERROR'):
6363
"""
6464
Initiate log files.
6565

MRdataset/dicom_utils.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,12 @@ def is_bids_file(filename: Union[str, Path]):
2929
# TODO: Add some criteria to skip certain files
3030
if 'derivatives' in str(filename):
3131
return False
32-
32+
if 'bidsignore' in str(filename):
33+
return False
34+
if 'sourcedata' in str(filename):
35+
return False
3336
# Regular expression pattern
34-
pattern = r'sub-\d+'
37+
pattern = r'sub-[^_]+'
3538
# Extracting substring using regex
3639
match = search(pattern, str(filename))
3740
if not match:

0 commit comments

Comments
 (0)