Skip to content

Commit

Permalink
Quick fix for TR connection if there is no TR info anywhere.
Browse files Browse the repository at this point in the history
  • Loading branch information
sgiavasis committed Feb 5, 2018
1 parent aa808a6 commit 4a47720
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
12 changes: 10 additions & 2 deletions CPAC/pipeline/cpac_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -1405,8 +1405,16 @@ def getNodeList(strategy):
# we might prefer to use the TR stored in the NIFTI header
# if not, use the value in the scan_params node
try:
workflow.connect(scan_params, 'tr',
func_slice_timing_correction, 'tr')
if c.TR:
if isinstance(c.TR, str):
if "None" in c.TR or "none" in c.TR:
pass
else:
workflow.connect(scan_params, 'tr',
func_slice_timing_correction, 'tr')
else:
workflow.connect(scan_params, 'tr',
func_slice_timing_correction, 'tr')
except Exception as xxx:
logger.info(
"Error connecting input 'tr' to func_slice_timing_"
Expand Down
13 changes: 10 additions & 3 deletions CPAC/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1489,6 +1489,10 @@ def get_scan_params(subject_id, scan, pipeconfig_tr, pipeconfig_tpattern,
if "None" in pipeconfig_tpattern:
pipeconfig_tpattern = None

if isinstance(pipeconfig_tr, str):
if "None" in pipeconfig_tr or "none" in pipeconfig_tr:
pipeconfig_tr = None

if data_config_scan_params:

if ".json" in data_config_scan_params:
Expand Down Expand Up @@ -1644,7 +1648,10 @@ def get_scan_params(subject_id, scan, pipeconfig_tr, pipeconfig_tpattern,
ref_slice, first_tr, last_tr))

# swap back in
tr = "{0}{1}".format(str(TR), unit)
if TR:
tr = "{0}{1}".format(str(TR), unit)
else:
tr = ""
tpattern = pattern
start_indx = first_tr
stop_indx = last_tr
Expand All @@ -1657,13 +1664,13 @@ def get_tr(tr):
Method to return TR in seconds
"""
import re
if 'None' in tr:
tr = None
if tr:
tr = re.search("\d+.\d+", str(tr)).group(0)
tr = float(tr)
if tr > 10:
tr = tr / 1000.0
else:
tr = ""
return tr


Expand Down

0 comments on commit 4a47720

Please sign in to comment.