Open rperea14 opened 3 years ago
Where are you installing ANTs from? That's unfortunate that there are binaries out there that aren't getting tagged with version information.
Hi @effigies, I believe these are binaries installed by the HPC-IT to be as a batch system :/
On a side note, I am attempting to output a set of commands to run them sequentially in a pipeline [e.g skull strip in step1 using ants, coreg in step2 skull stripped brains using elastix].
I realized that nipype has a file exists
validation, which prevents me to move forwards from step1 if step1 outputs are not created yet I want to reference them in step2. Is there any way to omit this validation step?
Here is a snippet of the error I get [bc. the outputs in step1 are not yet submitted to run]:
Traceback (most recent call last):
File "/pilothpc/dept/mdsa/MLAI/scripts/coreg_related/pipeline_210922/loop_preproc_TIV.py", line 270, in <module>
cmds = apply_elastix(braimask_T1w_fname, braimask_FLAIR_fname,
File "/pilothpc/dept/mdsa/MLAI/scripts/coreg_related/pipeline_210922/loop_preproc_TIV.py", line 41, in apply_elastix
reg.inputs.fixed_image =fixed_img
File "/home/rperea1/.conda/envs/nipype/lib/python3.9/site-packages/nipype/interfaces/base/traits_extension.py", line 330, in validate
value = super(File, self).validate(objekt, name, value, return_pathlike=True)
File "/home/rperea1/.conda/envs/nipype/lib/python3.9/site-packages/nipype/interfaces/base/traits_extension.py", line 135, in validate
self.error(objekt, name, str(value))
File "/home/rperea1/.conda/envs/nipype/lib/python3.9/site-packages/traits/base_trait_handler.py", line 74, in error
raise TraitError(
traits.trait_errors.TraitError: The 'fixed_image' trait of a RegistrationInputSpec instance must be a pathlike object or string representing an existing file, but a value of '/pilothpc/dept/mdsa/MLAI/datasets/MS_888MS001/derivatives/prepc_s1_antsv20201013_skstripN4/output_T1w_braimask.nii.gz' <class 'str'> was specified
I believe these are binaries installed by the HPC-IT to be as a batch system :/
Rough. If you know the version, before creating any ANTs interfaces, you can add:
import nipype
nipype.interfaces.ants.base.Info._version = "X.Y.Z"
Not great for writing code that can be used elsewhere, though... You could make it more conditional like:
import nipype
try:
nipype.interfaces.ants.base.Info.version()
except:
nipype.interfaces.ants.base.Info._version = "X.Y.Z"
If you're trying to connect up the outputs of one interface to another, then you should be using a workflow:
from nipype.pipeline import engine as pe
step1 = pe.Node(Step1Interface(), name="step1")
step2 = pe.Node(Step2Interface(), name="step2")
wf = pe.Workflow(name="workflow")
wf.connect([
(step1, step2, [("output-field1", "input-field1"),
("output-field2", "input-field2")]),
])
Then you use wf.run()
, rather than running each individually.
Is there any other way besides using workflows [looking to set some argument, validate
=False ] ?
The output files from different processing tools are tricky and need additional manipulation after I start another step [e.g. ants skull stripp generate dependent n4corrected, brainmask, brains. I will grab the brain.nii.gz and use it as a mov_img in step2, elastix ]...
Or can you refer me to a good tutorial for using the workflows?
Not really. The whole point is to be able to tell somebody, before they start a long workflow, if it's going to fail because a required input is missing. You can leave these fields blank and only set them when you're ready, however...
We highly recommend @miykael's nipype tutorials: https://miykael.github.io/nipype_tutorial/
And here's the introduction to workflows: https://miykael.github.io/nipype_tutorial/notebooks/basic_workflow.html
Summary
I am unable to execute bet.run() after the following lines:
The problem I get is:
Because when executing a command to get an ants version, the output looks like this: