Skip to content

Commit

Permalink
Better qsirecon_suffixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mattcieslak committed Dec 13, 2024
1 parent 3caa742 commit 14849a3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
4 changes: 3 additions & 1 deletion qsirecon/data/pipelines/ss3t_fod_autotrack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ nodes:
name: dsistudio_gqi
parameters:
method: gqi
qsirecon_suffix: DSIStudio
qsirecon_suffix: GQIAutoTrack
software: DSI Studio

# Performs the registration of QA+ISO to template
Expand Down Expand Up @@ -39,13 +39,15 @@ nodes:
mtnormalize: true
response:
algorithm: dhollander
qsirecon_suffix: SS3TAutoTrack

- action: fod_fib_merge
name: create_fod_fib
# to include the fib file and the map file
input: dsistudio_gqi
csd_input: ss3t_csd
# outputs include the FOD fib file and the map file is passed through
qsirecon_suffix: SS3TAutoTrack

- action: autotrack
input: dsistudio_gqi
Expand Down
18 changes: 12 additions & 6 deletions qsirecon/interfaces/converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,9 @@ def _run_interface(self, runtime):
# fname presuffix doesn't work with .fib.gz
fib_name = Path(self.inputs.reference_fib_file).name.replace(".odf.", ".odf.FOD.")
merged_fib_file = str(Path(runtime.cwd) / fib_name)
merged_fib_file = (
merged_fib_file if not merged_fib_file.endswith(".gz") else merged_fib_file[:-3]
)

combine_gqi_and_csd_fib_files(
path_gqi_fib=self.inputs.reference_fib_file,
Expand Down Expand Up @@ -276,19 +279,22 @@ def combine_gqi_and_csd_fib_files(path_gqi_fib: str, path_fod_fib: str, merged_f
fod_data = fast_load_fibgz(path_fod_fib)
merged_data = gqi_data.copy()

for gqi_key in gqi_data.keys():
for gqi_key in gqi_data:
if (
re.match(r"odf\d+", gqi_key)
or re.match(r"fa\d+", gqi_key)
or re.match(r"index\d+", gqi_key)
):
LOGGER.info(f"Deleting {gqi_key} from GQI data")
del merged_data[gqi_key]
if gqi_key in fod_data:
LOGGER.info(f"Copying {gqi_key} from FOD data")
merged_data[gqi_key] = fod_data[gqi_key]
else:
LOGGER.warning(f"Data for {gqi_key} not present in FOD Fib")
for fod_key in fod_data:
if (
re.match(r"odf\d+", fod_key)
or re.match(r"fa\d+", fod_key)
or re.match(r"index\d+", fod_key)
):
LOGGER.info(f"Copying {fod_key} from FOD data")
merged_data[fod_key] = fod_data[fod_key]

savemat(merged_fib, merged_data, format="4", appendmat=False)

Expand Down

0 comments on commit 14849a3

Please sign in to comment.