126
126
import logging
127
127
lgr = logging .getLogger ('heudiconv' )
128
128
129
- # Terminology to hamornise and use to name variables etc
129
+ # Terminology to harmonise and use to name variables etc
130
130
# experiment
131
131
# subject
132
132
# [session]
170
170
# QA
171
171
'43b67d9139e8c7274578b7451ab21123' :
172
172
[
173
- #('anat-scout.*', 'anat-scout_ses-{date}'),
173
+ # ('anat-scout.*', 'anat-scout_ses-{date}'),
174
174
# do not change it so we retain _ses-{date}
175
- #('anat-scout.*', 'anat-scout'),
175
+ # ('anat-scout.*', 'anat-scout'),
176
176
('BOLD_p2_s4_3\.5mm' , 'func_task-rest_acq-p2-s4-3.5mm' ),
177
177
('BOLD_p2_s4' , 'func_task-rest_acq-p2-s4' ),
178
178
('BOLD_p2_noprescannormalize' , 'func-bold_task-rest_acq-p2noprescannormalize' ),
254
254
[
255
255
('fmap_acq-discorr-dti-' , 'fmap_acq-dwi_dir-' ),
256
256
],
257
- #'022969bfde39c2940c114edf1db3fabc':
257
+ # '022969bfde39c2940c114edf1db3fabc':
258
258
# [ # should be applied only for ses-03!
259
259
# ('_acq-MPRAGE_ses-02', '_acq-MPRAGE_ses-03'),
260
260
# ],
261
261
# to be used only once for one interrupted accession but we cannot
262
262
# fix per accession yet
263
263
# '23763823d2b9b4b09dafcadc8e8edf21':
264
264
# [
265
- # ('anat-T1w_acq-MPRAGE', 'anat-T1w_acq-MPRAGE_run-06'),
265
+ # ('anat-T1w_acq-MPRAGE', 'anat-T1w_acq-MPRAGE_run-06'),
266
266
# ('anat_T2w', 'anat_T2w_run-06'),
267
267
# ('fmap_acq-3mm', 'fmap_acq-3mm_run-06'),
268
268
# ],
269
269
}
270
270
# there was also screw up in the locator specification
271
271
# so we need to fix in both
272
- #protocols2fix['67ae5e641ea9d487b6fdf56fb91aeb93'] = protocols2fix['022969bfde39c2940c114edf1db3fabc']
272
+ # protocols2fix['67ae5e641ea9d487b6fdf56fb91aeb93'] = protocols2fix['022969bfde39c2940c114edf1db3fabc']
273
273
274
274
# list containing StudyInstanceUID to skip -- hopefully doesn't happen too often
275
275
dicoms2skip = [
279
279
280
280
DEFAULT_FIELDS = {
281
281
# Let it just be in each json file extracted
282
- #'Manufacturer': "Siemens",
283
- #'ManufacturersModelName': "Prisma",
282
+ # 'Manufacturer': "Siemens",
283
+ # 'ManufacturersModelName': "Prisma",
284
284
"Acknowledgements" :
285
285
"We thank Terry Sacket and the rest of the DBIC (Dartmouth Brain Imaging "
286
286
"Center) personnel for assistance in data collection, and "
@@ -360,11 +360,13 @@ def md5sum(string):
360
360
m = hashlib .md5 (string .encode ())
361
361
return m .hexdigest ()
362
362
363
+
363
364
def get_study_description (seqinfo ):
364
365
# Centralized so we could fix/override
365
366
v = get_unique (seqinfo , 'study_description' )
366
367
return v
367
368
369
+
368
370
def get_study_hash (seqinfo ):
369
371
# XXX: ad hoc hack
370
372
return md5sum (get_study_description (seqinfo ))
@@ -427,8 +429,8 @@ def fix_seqinfo(seqinfo):
427
429
428
430
def ls (study_session , seqinfo ):
429
431
"""Additional ls output for a seqinfo"""
430
- #assert len(sequences) <= 1 # expecting only a single study here
431
- #seqinfo = sequences.keys()[0]
432
+ # assert len(sequences) <= 1 # expecting only a single study here
433
+ # seqinfo = sequences.keys()[0]
432
434
return ' study hash: %s' % get_study_hash (seqinfo )
433
435
434
436
@@ -440,15 +442,14 @@ def infotodict(seqinfo):
440
442
441
443
allowed template fields - follow python string module:
442
444
443
- item: index within category
444
- subject: participant id
445
+ item: index within category
446
+ subject: participant id
445
447
seqitem: run number during scanning
446
448
subindex: sub index within group
447
449
session: scan index for longitudinal acq
448
450
"""
449
451
seqinfo = fix_seqinfo (seqinfo )
450
452
lgr .info ("Processing %d seqinfo entries" , len (seqinfo ))
451
- and_dicom = ('dicom' , 'nii.gz' )
452
453
453
454
info = OrderedDict ()
454
455
skipped , skipped_unknown = [], []
@@ -471,7 +472,7 @@ def infotodict(seqinfo):
471
472
472
473
template = None
473
474
suffix = ''
474
- seq = []
475
+ # seq = []
475
476
476
477
# figure out type of image from s.image_info -- just for checking ATM
477
478
# since we primarily rely on encoded in the protocol name information
@@ -552,11 +553,11 @@ def infotodict(seqinfo):
552
553
raise ValueError ("Do not know image data type yet to make decision" )
553
554
seqtype_label = {
554
555
# might want explicit {file_index} ?
555
- # _epi for pipolar fieldmaps, see
556
+ # _epi for pepolar fieldmaps, see
556
557
# https://bids-specification.readthedocs.io/en/stable/04-modality-specific-files/01-magnetic-resonance-imaging-data.html#case-4-multiple-phase-encoded-directions-pepolar
557
558
'M' : 'epi' if 'dir' in series_info else 'magnitude' ,
558
559
'P' : 'phasediff' ,
559
- 'DIFFUSION' : 'epi' , # according to KODI those DWI are the EPIs we need
560
+ 'DIFFUSION' : 'epi' , # according to KODI those DWI are the EPIs we need
560
561
}[dcm_image_iod_spec ]
561
562
562
563
# label for dwi as well
@@ -634,7 +635,7 @@ def from_series_info(name):
634
635
run_label ,
635
636
seqtype_label ,
636
637
]
637
- # filter tose which are None, and join with _
638
+ # filter those which are None, and join with _
638
639
suffix = '_' .join (filter (bool , suffix_parts ))
639
640
640
641
# # .series_description in case of
@@ -736,9 +737,9 @@ def get_unique(seqinfos, attr):
736
737
return values .pop ()
737
738
738
739
739
- # TODO: might need to do groupping per each session and return here multiple
740
+ # TODO: might need to do grouping per each session and return here multiple
740
741
# hits, or may be we could just somehow demarkate that it will be multisession
741
- # one and so then later value parsed (again) in infotodict would be used???
742
+ # one and so then later value parsed (again) in infotodict would be used???
742
743
def infotoids (seqinfos , outdir ):
743
744
# decide on subjid and session based on patient_id
744
745
lgr .info ("Processing sequence infos to deduce study/session" )
@@ -788,7 +789,7 @@ def infotoids(seqinfos, outdir):
788
789
# although we might want an explicit '=' to note the same session as
789
790
# mentioned before?
790
791
if len (nonsign_vals ) > 1 :
791
- lgr .warning ( # raise NotImplementedError(
792
+ lgr .warning ( # raise NotImplementedError(
792
793
"Cannot deal with multiple sessions in the same study yet!"
793
794
" We will process until the end of the first session"
794
795
)
@@ -810,7 +811,7 @@ def infotoids(seqinfos, outdir):
810
811
# ... actually the same as with nonsign_vals, we just would need to figure
811
812
# out initial one if sign ones, and should make use of knowing
812
813
# outdir
813
- #raise NotImplementedError()
814
+ # raise NotImplementedError()
814
815
# we need to look at what sessions we already have
815
816
sessions_dir = os .path .join (outdir , locator , 'sub-' + subject )
816
817
prior_sessions = sorted (glob (os .path .join (sessions_dir , 'ses-*' )))
@@ -828,7 +829,6 @@ def infotoids(seqinfos, outdir):
828
829
else :
829
830
session = '001'
830
831
831
-
832
832
if study_description_hash == '9d148e2a05f782273f6343507733309d' :
833
833
session = 'siemens1'
834
834
lgr .info ('Imposing session {0}' .format (session ))
@@ -865,7 +865,7 @@ def parse_series_spec(series_spec):
865
865
# https://github.com/ReproNim/reproin/issues/14
866
866
# where PU: prefix is added by the scanner
867
867
series_spec = re .sub ("^[A-Z]*:" , "" , series_spec )
868
- series_spec = re .sub ("^WIP " , "" , series_spec ) # remove Philips WIP prefix
868
+ series_spec = re .sub ("^WIP " , "" , series_spec ) # remove Philips WIP prefix
869
869
870
870
# Remove possible suffix we don't care about after __
871
871
series_spec = series_spec .split ('__' , 1 )[0 ]
0 commit comments