ANTsX / ANTs

Advanced Normalization Tools (ANTs)
Apache License 2.0
1.21k stars 381 forks source link

Error message at antsApplyTransform #1735

Closed didatto closed 6 months ago

didatto commented 6 months ago

Operating system and version

macOS-14.0

CPU architecture

arm64 (Apple M1/M2)

ANTs code version

antsApplyTransforms

ANTs installation type

Downloaded Github release binaries

Summary of the problem

Hi,

I am trying to run this Linear transformation, however I keep getting the same error message, no matter how I modify the code. Could you please help and assist me in this matter? I tried several ways of using the square brackets, #, and curly bracket, '', and "" - but I keep receiving the error message. Even-though the out0GenericAffine.mat files are existing in the given folder, and the path was clearly defined previously.

Commands to reproduce the problem.

antsApplyTransforms -d 3 -i "$ROI_mask" -r "$b0brain" \ -t "$T1_folder"/b0_T1/out0GenericAffine.mat [1] \ -t "$T1_folder"/out0GenericAffine.mat [1] \ -t "$T1_folder/out1InverseWarp.nii.gz" \ -n NearestNeighbor -o "$T1_folder/new_mask_dir/${filename_mask}_in_T2.nii.gz" -v

Output of the command with verbose output.

~ % antsApplyTransforms -d 3 -i "$ROI_mask" -r "$b0brain" \ -t "$T1_folder"/b0_T1/out0GenericAffine.mat [1] \ -t "$T1_folder"/out0GenericAffine.mat'[1]' \ -t "$T1_folder/out1InverseWarp.nii.gz" \ -n NearestNeighbor -o "$T1_folder/new_mask_dir/${filename_mask}_in_T2.nii.gz" -v

Using double precision for computations. Input scalar image: /Users/anneliesvantwesteinde/precuneus/precuneus_ROI_Left.nii.gz Reference image: /Volumes/Diana/Preprocessed/DTI/Addison_AllControls/ADDI_013/nodif.nii.gz Transform file does not exist: 1 Can't read initial transform 1

Data to reproduce the problem

Sorry the files are too big to upload, even if I compressed them.

gdevenyi commented 6 months ago

Why is [1] in the command? This is the error.

didatto commented 6 months ago

Why is [1] in the command? This is the error.

Hi Gabriel, This was the original code I used. Got the same error. antsApplyTransforms -d 3 -i "$ROI_mask" -r $b0brain -t ["$T1_folder"/b0_T1/out0GenericAffine.mat,1] -t ["$T1_folder"/T1_MNI/out0GenericAffine.mat,1] -t "$T1_folder"/T1_MNI/out1InverseWarp.nii.gz -n NearestNeighbor -o "$new_mask_dir"/$filename_mask/"$filename_mask"_in_T2.nii.gz -v

gdevenyi commented 6 months ago

That's not the same command, this is telling ants to invert the transform before applying, and should be a valid command.

Based on your prompt character you're not using bash.

Can you run "bash" and try the command again, and provide the full output.

didatto commented 6 months ago

Thank you for your reply. I changed the zsh to bash, still received the error message:

bash-3.2$ antsApplyTransforms -d 3 -i "$ROI_mask" -r $b0brain -t ["$T1_folder"/b0_T1/out0GenericAffine.mat,1] -t ["$T1_folder"/T1_MNI/out0GenericAffine.mat,1] -t "$T1_folder"/T1_MNI/out1InverseWarp.nii.gz -n NearestNeighbor -o "$new_mask_dir"/$filename_mask/"$filename_mask"_in_T2.nii.gz -v Using double precision for computations. Input scalar image: /Users/anneliesvantwesteinde/precuneus/precuneus_ROI_Left.nii.gz Reference image: /Volumes/Diana/Preprocessed/DTI/Addison_AllControls/ADDI_013/nodif.nii.gz Transform file does not exist: /Volumes/Diana/Preprocessed/DTI/Test_BedpostX/ANTs/T1_MNI/T1_MNI/out1InverseWarp.nii.gz Can't read initial transform /Volumes/Diana/Preprocessed/DTI/Test_BedpostX/ANTs/T1_MNI/T1_MNI/out1InverseWarp.nii.gz bash-3.2$

This is the full code I was following: At line 54 is this code: antsApplyTransforms -d 3 -i "$ROI_mask" -r $b0brain -t ["$T1_folder"/b0_T1/out0GenericAffine.mat,1] -t ["$T1_folder"/T1_MNI/out0GenericAffine.mat,1] -t "$T1_folder"/T1_MNI/out1InverseWarp.nii.gz -n NearestNeighbor -o "$new_mask_dir"/$filename_mask/"$filename_mask"_in_T2.nii.gz -v Screenshot 2024-05-02 at 13 16 54 Screenshot 2024-05-02 at 13 18 50

gdevenyi commented 6 months ago

Transform file does not exist: /Volumes/Diana/Preprocessed/DTI/Test_BedpostX/ANTs/T1_MNI/T1_MNI/out1InverseWarp.nii.gz

Does that file exist?

didatto commented 6 months ago

Bash was indeed an error, you were right, and the path was defined twice. Thank you for your help, now it runs.
Have a nice day :-)