KCL-BMEIS / niftyreg

This project contains command line tools to perform rigid, affine and non-linear registration of nifti or analyse images as well as utilities
BSD 3-Clause "New" or "Revised" License
141 stars 42 forks source link

Niftyreg (is there other option in the reg_aladin that generates parameters' to be used in the Reg_resample?) #98

Closed skgtohn closed 1 year ago

skgtohn commented 1 year ago

Hi,

I used the niftyreg reigstraiton method with this command: reg_aladin -ref $REF_IMG -flo ${file} -res "${OUTPUT_DIR}/$(basename ${file%..})_affine.nii.gz" -aff "${OUTPUT_DIR}/$(basename ${file%..})_affine.txt" -ln 3 -maxit 1000

So the registered output is generated based on the code(ep2d_perf_p2_4mm-0002_affine_masked.nii.gz ep2d_perf_p2_4mm-0002.nii_affine.txt ep2d_perf_p2_4mm-0002.nii_affine.nii.gz). And I want to use the registration parameters to my rest of imaging. So i used the txt file with the command using Reg_resample(Reg resample - CMIC).

And this is the code ( # Apply transformation reg_resample -ref $REF_IMG -flo $perf_file -trans $TRANSFORM_FILE -res $OUT_IMG). However, the reg_resample command doesn’t seem to accept the txt files. In this case, which format is needed? Or is there other option in the reg_aladin that generates parameters’ to be used in the Reg_resample?

Thank you!

mmodat commented 1 year ago

Hi,

You should be able to use the affine matrix generated by reg_aladin ("${OUTPUT_DIR}/$(basename ${file%..})_affine.txt") as an input to reg_resample. What error message did you obtain?

skgtohn commented 1 year ago

Thanks for the quick response.

This is the affine matrix.txt content I got from the reg_aladin.

                                    1.001433 -0.006299393 0.008205931

-0.6460585 0.006189371 1.009896 0.002902182 0.9270121 -0.000993318 -0.002085363 0.9903216 3.242534 0 0 0 1

And this is the command I used for the command reg_resample.

                                  # Apply transformation
        reg_resample -ref $REF_IMG -flo $perf_file -trans

$TRANSFORM_FILE -res $OUT_IMG And this is the error message I got.

** ERROR (nifti_image_read): failed to find header file for '/SAN/medic/CEST/data/pyrad_curtis/P074/processed_hd_glio/advanced_imaging/niftyreg/ep2d_perf_p2_4mm-0002.nii_affine.txt' Segmentation fault.

I greatly appreciate any help you can provide on this matter.

Best, Curtis

On Mon, Jul 10, 2023 at 12:41 PM Marc Modat @.***> wrote:

Hi,

You should be able to use the affine matrix generated by reg_aladin ("${OUTPUT_DIR}/$(basename ${file%..})_affine.txt") as an input to reg_resample. What error message did you obtain?

— Reply to this email directly, view it on GitHub https://github.com/KCL-BMEIS/niftyreg/issues/98#issuecomment-1628795060, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANTHXEHPJL3G4GU3RQ7Z54LXPPS55ANCNFSM6AAAAAA2DZX5SQ . You are receiving this because you authored the thread.Message ID: @.***>

skgtohn commented 1 year ago

Here I also attach the full script I've been using for the reg_resample just in case.

On Mon, Jul 10, 2023 at 12:54 PM curtis sohn @.***> wrote:

Thanks for the quick response.

This is the affine matrix.txt content I got from the reg_aladin.

                                      1.001433 -0.006299393 0.008205931

-0.6460585 0.006189371 1.009896 0.002902182 0.9270121 -0.000993318 -0.002085363 0.9903216 3.242534 0 0 0 1

And this is the command I used for the command reg_resample.

                                  # Apply transformation
        reg_resample -ref $REF_IMG -flo $perf_file -trans

$TRANSFORM_FILE -res $OUT_IMG And this is the error message I got.

** ERROR (nifti_image_read): failed to find header file for '/SAN/medic/CEST/data/pyrad_curtis/P074/processed_hd_glio/advanced_imaging/niftyreg/ep2d_perf_p2_4mm-0002.nii_affine.txt' Segmentation fault.

I greatly appreciate any help you can provide on this matter.

Best, Curtis

On Mon, Jul 10, 2023 at 12:41 PM Marc Modat @.***> wrote:

Hi,

You should be able to use the affine matrix generated by reg_aladin ("${OUTPUT_DIR}/$(basename ${file%..})_affine.txt") as an input to reg_resample. What error message did you obtain?

— Reply to this email directly, view it on GitHub https://github.com/KCL-BMEIS/niftyreg/issues/98#issuecomment-1628795060, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANTHXEHPJL3G4GU3RQ7Z54LXPPS55ANCNFSM6AAAAAA2DZX5SQ . You are receiving this because you authored the thread.Message ID: @.***>

mmodat commented 1 year ago

You might be using an quite dated version (I need to do a new release, waiting to finalise the GPU re-integration) as it seems reg_resample think your file is a nifti file. Could you try using the -aff argument instead of -trans?

skgtohn commented 1 year ago

Thanks a lot! I found that I was using niftyreg_v1.5.43. So i found the nifty_reg-1.3.9 version in a cluster.

And it did worked with the -aff argument.

Thanks for your support.

On Mon, Jul 10, 2023 at 1:44 PM Marc Modat @.***> wrote:

You might be using an quite dated version (I need to do a new release, waiting to finalise the GPU re-integration) as it seems reg_resample think your file is a nifti file. Could you try using the -aff argument instead of -trans?

— Reply to this email directly, view it on GitHub https://github.com/KCL-BMEIS/niftyreg/issues/98#issuecomment-1628884114, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANTHXEGYCGZKOUU6OJXLPF3XPP2KBANCNFSM6AAAAAA2DZX5SQ . You are receiving this because you authored the thread.Message ID: @.***>