Skip to content

Commit

Permalink
fixed up location of collate_parcs, i.e. within all_parcs workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
adsouza committed Nov 18, 2024
1 parent 79ded64 commit f688029
Showing 1 changed file with 73 additions and 50 deletions.
123 changes: 73 additions & 50 deletions src/australianimagingservice/mri/human/neuro/t1w/preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -1019,55 +1019,6 @@ def join_task_catalogue(
),
]
)

wf.add(
FunctionTask(
collate_parcs,
name="collate_parcs",
input_spec=SpecInfo(
name="CollateParcsInputs",
bases=(BaseSpec,),
fields=[(p, Mif) for p in parcellation_list],
),
output_spec=SpecInfo(
name="CollateParcsOutputs",
bases=(BaseSpec,),
fields=[("out_dir", DirectoryOf[Mif])], # type: ignore[misc]
),
out_dir="out_dir",
)
)

for parcellation in parcellation_list:

wf.add(
single_parc(
t1w=wf.lzin.t1w,
parcellation=parcellation,
freesurfer_home=freesurfer_home,
mrtrix_lut_dir=mrtrix_lut_dir,
cache_dir=cache_dir,
fs_license=fs_license,
fastsurfer_executable=fastsurfer_executable,
fastsurfer_python=fastsurfer_python,
name=parcellation,
)
)

setattr(
wf.collate_parcs.inputs,
parcellation,
getattr(wf, parcellation).lzout.parc_image,
)

wf.set_output(("parcellations", wf.collate_parcs.lzout.out_dir))
wf.set_output(("vis_image_fsl", wf.desikan.lzout.vis_image_fsl))
wf.set_output(("ftt_image_fsl", wf.desikan.lzout.ftt_image_fsl))
wf.set_output(("vis_image_freesurfer", wf.desikan.lzout.vis_image_freesurfer))
wf.set_output(("ftt_image_freesurfer", wf.desikan.lzout.ftt_image_freesurfer))
wf.set_output(("vis_image_hsvs", wf.desikan.lzout.vis_image_hsvs))
wf.set_output(("ftt_image_hsvs", wf.desikan.lzout.ftt_image_hsvs))

return wf


Expand Down Expand Up @@ -1118,11 +1069,59 @@ def all_parcs(
}

wf = Workflow(
name="t1_processing_pipeline",
name=name,
input_spec=input_spec,
cache_dir=cache_dir,
)

wf.add(
FunctionTask(
collate_parcs,
name="collate_parcs",
input_spec=SpecInfo(
name="CollateParcsInputs",
bases=(BaseSpec,),
fields=[(p, Mif) for p in parcellation_list],
),
output_spec=SpecInfo(
name="CollateParcsOutputs",
bases=(BaseSpec,),
fields=[("out_dir", DirectoryOf[Mif])], # type: ignore[misc]
),
out_dir="out_dir",
)
)

for parcellation in parcellation_list:

wf.add(
single_parc(
t1w=wf.lzin.t1w,
parcellation=parcellation,
freesurfer_home=freesurfer_home,
mrtrix_lut_dir=mrtrix_lut_dir,
cache_dir=cache_dir,
fs_license=fs_license,
fastsurfer_executable=fastsurfer_executable,
fastsurfer_python=fastsurfer_python,
name=parcellation,
)
)

setattr(
wf.collate_parcs.inputs,
parcellation,
getattr(wf, parcellation).lzout.parc_image,
)

wf.set_output(("parcellations", wf.collate_parcs.lzout.out_dir))
wf.set_output(("vis_image_fsl", wf.desikan.lzout.vis_image_fsl))
wf.set_output(("ftt_image_fsl", wf.desikan.lzout.ftt_image_fsl))
wf.set_output(("vis_image_freesurfer", wf.desikan.lzout.vis_image_freesurfer))
wf.set_output(("ftt_image_freesurfer", wf.desikan.lzout.ftt_image_freesurfer))
wf.set_output(("vis_image_hsvs", wf.desikan.lzout.vis_image_hsvs))
wf.set_output(("ftt_image_hsvs", wf.desikan.lzout.ftt_image_hsvs))

return wf


Expand All @@ -1142,3 +1141,27 @@ def collate_parcs(out_dir: Path = None, **parcs: "Mif") -> "DirectoryOf[Mif]":

wf = all_parcs(*args) # type: ignore[arg-type]
wf(t1w=sys.argv[1])
# if __name__ == "__main__":
# import sys

# # Expecting the first argument to be the T1-weighted image path
# t1w_path = sys.argv[1]

# # Provide sensible default values or pass from command-line arguments
# # freesurfer_home = "/Applications/freesurfer/" # Adjust this path as per your setup
# # mrtrix_lut_dir = "/Users/arkievdsouza/mrtrix3/share/mrtrix3/labelconvert/" # Adjust this path as per your setup
# # cache_dir = "/Users/arkievdsouza/git/t1-pipeline/working-dir/" # Temporary directory for cache
# # fs_license = (
# # "/Applications/freesurfer/license.txt " # Path to the FreeSurfer license file
# # )

# # Pass the arguments explicitly
# wf = all_parcs(*sys.argv[1])
# # freesurfer_home=freesurfer_home,
# # mrtrix_lut_dir=mrtrix_lut_dir,
# # cache_dir=cache_dir,
# # fs_license=fs_license,
# # ) # type: ignore[arg-type]

# # # Run the workflow with the T1-weighted image as input
# wf(t1w=t1w_path)

0 comments on commit f688029

Please sign in to comment.