@@ -285,7 +285,7 @@ def download_scan_unformatted(self, scan, dest, scan_repl_dict, bids_num_len,
285285 from glob import glob
286286 if scan not in self .scan_dict .keys ():
287287 print ('{scan} is not available for download' .format (scan = scan ))
288- return 1
288+ return 0
289289
290290 # No easy way to check for complete download
291291 # the session label (e.g. 20180613)
@@ -294,10 +294,7 @@ def download_scan_unformatted(self, scan, dest, scan_repl_dict, bids_num_len,
294294 scan_par = self .scan_dict [scan ].parent ()
295295 # the number id given to a scan (1, 2, 3, 400, 500)
296296 scan_id = self .scan_dict [scan ].id ()
297- # TODO: change this hardcoding
298- if scan_id == '1' or scan_id == '2' :
299- print ('scan is a localizer or setup scan' )
300- return 0
297+
301298 bids_scan = scan_repl_dict [scan ]
302299 # PU:task-rest_bold -> PU_task_rest_bold
303300 scan_fmt = re .sub (r'[\-\:\ \(\)]' , '_' , scan )
@@ -342,7 +339,11 @@ def download_scan_unformatted(self, scan, dest, scan_repl_dict, bids_num_len,
342339 scan_pattern = re .compile (SCAN_EXPR )
343340
344341 scan_pattern_dict = re .search (scan_pattern , bids_scan ).groupdict ()
345-
342+ # check if the modality is empty
343+ if scan_pattern_dict ['modality' ] is None :
344+ print ('{scan} is not in BIDS, not converting' .format (scan = scan ))
345+ return 0
346+
346347 # build up the bids directory
347348 bids_dir = os .path .join (dest , sub_name , ses_name , scan_pattern_dict ['modality' ])
348349
@@ -407,12 +408,10 @@ def download_scan(self, scan, dest):
407408 scan_par = self .scan_dict [scan ].parent ()
408409 # the number id given to a scan (1, 2, 3, 400, 500)
409410 scan_id = self .scan_dict [scan ].id ()
410- if scan_id == '1' or scan_id == '2' :
411- print ('scan is a localizer or setup scan' )
412- return 0
413411
414412 # PU:task-rest_bold -> PU_task_rest_bold
415- scan_dir = scan_id + '-' + scan .replace ('-' , '_' ).replace (':' , '_' ).replace (' ' , '_' )
413+ scan_fmt = re .sub (r'[\-\:\ \(\)]' , '_' , scan )
414+ scan_dir = scan_id + '-' + scan_fmt
416415
417416 dcm_outdir = os .path .join (dest , 'sourcedata' )
418417 if not os .path .isdir (dcm_outdir ):
@@ -448,7 +447,9 @@ def download_scan(self, scan, dest):
448447 # WARNING they will only be in the correct order if I am using
449448 # python3.6+
450449 scan_pattern_dict = re .search (scan_pattern , scan ).groupdict ()
451-
450+ if scan_pattern_dict ['modality' ] is None :
451+ print ('{scan} is not in BIDS, not converting' .format (scan = scan ))
452+ return 0
452453 # build up the bids directory
453454 bids_dir = os .path .join (dest , sub_name , ses_name , scan_pattern_dict ['modality' ])
454455
0 commit comments