You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Summary
I am attempting to execute antsRegistration via nipype.interfaces.ants import Registration but get an error stating that the command "antsRegistration" found on my host. I have ANTs loaded on the terminal and can run the command directly here. I can see that there was a similar issue (#3202) but that this could be solved by updating the PATH.
I cannot find documentation on how to update my PATH to allow my command to work.
I believe I am working in ~/.cshrc
Actual behavior
defants_linear_T1w_NM_registration(T1_corrected_path, NM_corrected_path, output_dir, subject_id):
""" Perform ANTs rigid registration to align the NM image to the T1-weighted image using the Nipype ANTs wrapper. """# Define output file pathsoutput_prefix=os.path.join(output_dir, f"{subject_id}_NM_space-T1w")
warped_image_path=f"{output_prefix}_Warped.nii.gz"inverse_warped_image_path=f"{output_prefix}_InverseWarped.nii.gz"affine_transform_path=f"{output_prefix}_Affine.mat"# Create registration objectreg=Registration()
# Set input imagesreg.inputs.fixed_image=T1_corrected_pathreg.inputs.moving_image=NM_corrected_path# Set output transform prefixreg.inputs.output_transform_prefix=output_prefix# Define transformationsreg.inputs.transforms= ["Rigid"]
reg.inputs.transform_parameters= [(0.1,)] # Equivalent to --transform Rigid[0.1]# Convergence parametersreg.inputs.number_of_iterations= [[100, 70, 50, 20]] # Corresponds to --convergence [100x70x50x20, 1e-6, 10]reg.inputs.convergence_threshold= [1e-6]
reg.inputs.convergence_window_size= [10]
# Shrink factors and smoothing sigmasreg.inputs.shrink_factors= [[8, 4, 2, 1]] # Corresponds to --shrink-factors 8x4x2x1reg.inputs.smoothing_sigmas= [[3, 2, 1, 0]] # Corresponds to --smoothing-sigmas 3x2x1x0voxreg.inputs.sigma_units= ["vox"]
# Similarity metricreg.inputs.metric= ["CC"] # Corresponds to --metric CC[T1_corrected_path, NM_corrected_path,1,4]reg.inputs.metric_weight= [1]
reg.inputs.radius_or_number_of_bins= [4]
# Histogram matching & intensity settingsreg.inputs.use_histogram_matching= [False] # Corresponds to --use-histogram-matching 0reg.inputs.winsorize_lower_quantile=0.005# Corresponds to --winsorize-image-intensities [0.005, 0.995]reg.inputs.winsorize_upper_quantile=0.995# Interpolation methodreg.inputs.interpolation="Linear"# Corresponds to --interpolation Linear# Output file settingsreg.inputs.output_warped_image=warped_image_pathreg.inputs.output_inverse_warped_image=inverse_warped_image_path# Run the registrationreg.run()
print(f"NM-to-T1 registration saved to {warped_image_path}")
Traceback (most recent call last):
File "/data/project/CARDS/kcl_nm/scripts/main_script.py", line 119, in <module>
main()
File "/data/project/CARDS/kcl_nm/scripts/main_script.py", line 109, in main
process_all_subjects(
File "/data/project/CARDS/kcl_nm/scripts/main_script.py", line 94, in process_all_subjects
process_subject(nifti_dir, output_dir, subject_id, templates_dir, results_dir, apply_robustfov_flag)
File "/data/project/CARDS/kcl_nm/scripts/main_script.py", line 51, in process_subject
ants_linear_T1w_NM_registration(T1_corrected_path, NM_corrected_path, subject_output_path, subject_id)
File "/data/project/CARDS/kcl_nm/scripts/image_processing_functions_wrapper.py", line 93, in ants_linear_T1w_NM_registration
reg.run()
File "/home/k1754339/.conda/envs/kcl_nm/lib/python3.11/site-packages/nipype/interfaces/base/core.py", line 397, in run
runtime = self._run_interface(runtime)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/k1754339/.conda/envs/kcl_nm/lib/python3.11/site-packages/nipype/interfaces/ants/registration.py", line 1020, in _run_interface
runtime = super(Registration, self)._run_interface(runtime)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/k1754339/.conda/envs/kcl_nm/lib/python3.11/site-packages/nipype/interfaces/base/core.py", line 752, in _run_interface
raise IOError(
OSError: No command "antsRegistration" found on host grid03.nan.kcl.ac.uk. Please check that the corresponding package is installed.
Versions:
ants/2.4.0
nipype/1.8.6
The text was updated successfully, but these errors were encountered:
Many thanks for this prompt response. This fixes the problem. I do have two more quick queries:
Is it possible to specify that I want to install ants (v2.4.0)?
With my current pipeline I ask users to do the following before running my code:
module load fsl/6.0.5.2
module load freesurfer/7.3.2
source /software/system/freesurfer/7.3.2/SetUpFreeSurfer.csh
Is it possible to conda install these packages to skip this step?
Summary
I am attempting to execute antsRegistration via nipype.interfaces.ants import Registration but get an error stating that the command "antsRegistration" found on my host. I have ANTs loaded on the terminal and can run the command directly here. I can see that there was a similar issue (#3202) but that this could be solved by updating the PATH.
I cannot find documentation on how to update my PATH to allow my command to work.
I believe I am working in ~/.cshrc
Actual behavior
Versions:
ants/2.4.0
nipype/1.8.6
The text was updated successfully, but these errors were encountered: