@@ -551,7 +551,10 @@ def infotodict(seqinfo):
551
551
if not dcm_image_iod_spec :
552
552
raise ValueError ("Do not know image data type yet to make decision" )
553
553
seqtype_label = {
554
- 'M' : 'magnitude' , # might want explicit {file_index} ?
554
+ # might want explicit {file_index} ?
555
+ # _epi for pipolar fieldmaps, see
556
+ # 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
+ 'M' : 'epi' if 'dir' in series_info else 'magnitude' ,
555
558
'P' : 'phasediff' ,
556
559
'DIFFUSION' : 'epi' , # according to KODI those DWI are the EPIs we need
557
560
}[dcm_image_iod_spec ]
@@ -610,12 +613,23 @@ def infotodict(seqinfo):
610
613
if s .is_motion_corrected and 'rec-' in series_info .get ('bids' , '' ):
611
614
raise NotImplementedError ("want to add _acq-moco but there is _acq- already" )
612
615
616
+ def from_series_info (name ):
617
+ """A little helper to provide _name-value if series_info knows it
618
+
619
+ Returns None otherwise
620
+ """
621
+ if series_info .get (name ):
622
+ return "%s-%s" % (name , series_info [name ])
623
+ else :
624
+ return None
625
+
613
626
suffix_parts = [
614
- None if not series_info . get ('task' ) else "task-%s" % series_info [ 'task' ] ,
615
- None if not series_info . get ('acq' ) else "acq-%s" % series_info [ 'acq' ] ,
627
+ from_series_info ('task' ),
628
+ from_series_info ('acq' ),
616
629
# But we want to add an indicator in case it was motion corrected
617
630
# in the magnet. ref sample /2017/01/03/qa
618
631
None if not s .is_motion_corrected else 'rec-moco' ,
632
+ from_series_info ('dir' ),
619
633
series_info .get ('bids' ),
620
634
run_label ,
621
635
seqtype_label ,
@@ -903,7 +917,7 @@ def split2(s):
903
917
.replace ('_' , 'X' ).replace ('-' , 'X' ) \
904
918
.replace ('(' , '{' ).replace (')' , '}' ) # for Philips
905
919
906
- if key in ['ses' , 'run' , 'task' , 'acq' ]:
920
+ if key in ['ses' , 'run' , 'task' , 'acq' , 'dir' ]:
907
921
# those we care about explicitly
908
922
regd [{'ses' : 'session' }.get (key , key )] = sanitize_str (value )
909
923
else :
0 commit comments