Align ROI mask to functional scan (AIL vs RAI)

Dear AFNIers,

I would like to use a WM lesion map, derived from a FLAIR image with the Lesion Segmentation Toolbox (LST) in SPM, as a mask to extract values of interest from a functional scan. However, I’m having troubles getting the images aligned properly. The FLAIR has AIL orientation and the functional scan RAI orientation. The LST output is in TLRC space (but seems aligned to a MNI template).

I’ve searched the message board and used 3dresample, 3dWarp, and 3dAllineate. The latter seems to work best but the output is not quite a match although the orientation differences seem to be corrected. This may be due to template differences? Below, you find tons of information on the orientation and geometry of the images as well as some example commands and unsuccessful approaches.

An aside question: the scans are built with dcm2nii - could this cause potential issues with left-right flip? It doesn’t seem so.

I’d be really grateful for any tips and suggestions!

Thanks so much in advance,

Nic

############################ SCAN INFORMATION ############################

FLAIR

T2SPACEFLAIRvb17bw651subj.nii

Template Space: ORIG
Data Axes Tilt: Oblique (10.911 deg. from plumb)
Data Axes Approximate Orientation:
first (x) = Anterior-to-Posterior
second (y) = Inferior-to-Superior
third (z) = Left-to-Right [-orient AIL]
R-to-L extent: -73.036 [R] -to- 101.965 [L] -step- 1.000 mm [176 voxels]
A-to-P extent: -168.287 [A] -to- 86.713 [P] -step- 1.000 mm [256 voxels]
I-to-S extent: -174.799 [I] -to- 80.201 [S] -step- 1.000 mm [256 voxels]
R-to-L center: 14.464 [L]
A-to-P center: -40.787 [A]
I-to-S center: -47.299 [I]

FUNCTIONAL SCAN

pb00.subj.r01.tcat+orig.

Template Space: ORIG
Data Axes Tilt: Oblique (10.912 deg. from plumb)
Data Axes Approximate Orientation:
first (x) = Right-to-Left
second (y) = Posterior-to-Anterior
third (z) = Inferior-to-Superior [-orient RPI]
R-to-L extent: -95.113 [R] -to- 93.887 [L] -step- 3.000 mm [ 64 voxels]
A-to-P extent: -119.949 [A] -to- 69.051 [P] -step- 3.000 mm [ 64 voxels]
I-to-S extent: -112.225 [I] -to- 4.025 [S] -step- 3.750 mm [ 32 voxels]
R-to-L center: -0.613 [R]
A-to-P center: -25.449 [A]
I-to-S center: -54.100 [I]

pb02.subj.r01.volreg+tlrc

Template Space: TT_N27
Data Axes Tilt: Plumb
Data Axes Orientation:
first (x) = Right-to-Left
second (y) = Anterior-to-Posterior
third (z) = Inferior-to-Superior [-orient RAI]
R-to-L extent: -79.500 [R] -to- 79.500 [L] -step- 3.000 mm [ 54 voxels]
A-to-P extent: -79.500 [A] -to- 109.500 [P] -step- 3.000 mm [ 64 voxels]
I-to-S extent: -63.500 [I] -to- 83.500 [S] -step- 3.000 mm [ 50 voxels]
R-to-L center: 0.000
A-to-P center: 15.000 [P]
I-to-S center: 10.000 [S]

LST OUTPUT

ples_lpa_mrT2SPACEFLAIRvb17bw651subj.nii

Template Space: TLRC
Data Axes Tilt: Oblique (11.275 deg. from plumb)
Data Axes Approximate Orientation:
first (x) = Anterior-to-Posterior
second (y) = Inferior-to-Superior
third (z) = Left-to-Right [-orient AIL]
R-to-L extent: -78.326 [R] -to- 96.674 [L] -step- 1.000 mm [176 voxels]
A-to-P extent: -164.654 [A] -to- 90.346 [P] -step- 1.000 mm [256 voxels]
I-to-S extent: -178.495 [I] -to- 76.505 [S] -step- 1.000 mm [256 voxels]
R-to-L center: 9.174 [L]
A-to-P center: -37.154 [A]
I-to-S center: -50.995 [I]

############################ EXAMPLE COMMANDS ############################

ALIGN LST OUTPUT TO FUNCTIONAL SCAN

The _al output seems to mostly align with the functional scan but is tilted to the left in the AFNI viewer. The LST output is in AIL and functional scan in RAI → using 3dresample but the probability map is totally off then.

3dAllineate -base pb02.subj.r01.volreg+tlrc -input ples_lpa_mrT2SPACEFLAIRvb17bw651subj.nii -1Dmatrix_save al_matrix_1mm -mast_dxyz 1 -prefix lesion_map_al_1mm

3dresample -master pb02.subj.r01.volreg+tlrc -input ples_lpa_mrT2SPACEFLAIRvb17bw651subj.nii -prefix ples_lpa_mrT2SPACEFLAIRvb17bw651subj_reoriented_3mm

lesion_map_al_1mm+tlrc

Template Space: TT_N27
Data Axes Tilt: Plumb
Data Axes Orientation:
first (x) = Right-to-Left
second (y) = Anterior-to-Posterior
third (z) = Inferior-to-Superior [-orient RAI]
R-to-L extent: -80.500 [R] -to- 80.500 [L] -step- 1.000 mm [162 voxels]
A-to-P extent: -80.500 [A] -to- 110.500 [P] -step- 1.000 mm [192 voxels]
I-to-S extent: -64.500 [I] -to- 84.500 [S] -step- 1.000 mm [150 voxels]
R-to-L center: 0.000
A-to-P center: 15.000 [P]
I-to-S center: 10.000 [S]

ples_lpa_mrT2SPACEFLAIRvb17bw651subj_reoriented_3mm+tlrc.

Template Space: TLRC
Data Axes Tilt: Plumb
Data Axes Orientation:
first (x) = Right-to-Left
second (y) = Anterior-to-Posterior
third (z) = Inferior-to-Superior [-orient RAI]
R-to-L extent: -79.500 [R] -to- 79.500 [L] -step- 3.000 mm [ 54 voxels]
A-to-P extent: -79.500 [A] -to- 109.500 [P] -step- 3.000 mm [ 64 voxels]
I-to-S extent: -63.500 [I] -to- 83.500 [S] -step- 3.000 mm [ 50 voxels]
R-to-L center: 0.000
A-to-P center: 15.000 [P]
I-to-S center: 10.000 [S]

REORIENTING FROM AIL TO RAI BEFORE ALIGNMENT OF LST OUTPUT TO FUNCTIONAL SCAN

#Again, the reoriented_pre_al output seems to mostly align with the functional scan but is tilted to the left in the AFNI viewer.

3dresample -master pb02.subj.r01.volreg+tlrc -dxyz 1.0 1.0 1.0 -input ples_lpa_mrT2SPACEFLAIRvb17bw651subj.nii -prefix ples_lpa_mrT2SPACEFLAIRvb17bw651subj_reoriented

3dAllineate -base pb02.subj.r01.volreg+tlrc -input ples_lpa_mrT2SPACEFLAIRvb17bw651subj_reoriented+tlrc. -1Dmatrix_save al_matrix_1mm_reoriented -mast_dxyz 1 -prefix lesion_map_al_1mm_reoriented_pre_al

ples_lpa_mrT2SPACEFLAIRvb17bw651subj_reoriented

Template Space: TLRC
Data Axes Tilt: Plumb
Data Axes Orientation:
first (x) = Right-to-Left
second (y) = Anterior-to-Posterior
third (z) = Inferior-to-Superior [-orient RAI]
R-to-L extent: -80.500 [R] -to- 80.500 [L] -step- 1.000 mm [162 voxels]
A-to-P extent: -80.500 [A] -to- 110.500 [P] -step- 1.000 mm [192 voxels]
I-to-S extent: -64.500 [I] -to- 84.500 [S] -step- 1.000 mm [150 voxels]
R-to-L center: 0.000
A-to-P center: 15.000 [P]
I-to-S center: 10.000 [S]

lesion_map_al_1mm_reoriented_pre_al+tlrc

Template Space: TT_N27
Data Axes Tilt: Plumb
Data Axes Orientation:
first (x) = Right-to-Left
second (y) = Anterior-to-Posterior
third (z) = Inferior-to-Superior [-orient RAI]
R-to-L extent: -80.500 [R] -to- 80.500 [L] -step- 1.000 mm [162 voxels]
A-to-P extent: -80.500 [A] -to- 110.500 [P] -step- 1.000 mm [192 voxels]
I-to-S extent: -64.500 [I] -to- 84.500 [S] -step- 1.000 mm [150 voxels]
R-to-L center: 0.000
A-to-P center: 15.000 [P]
I-to-S center: 10.000 [S]

############################ OTHER UNSUCCESSFUL APPROACHES ############################

Resampling FLAIR to functional scan before LST and then resample output to functional scan to address differences in orientation

Resampling the FLAIR LST image from which the lesion map was created bc perhaps the issue is that this is a ROI mask, not the “full” image

Resample functional scan to probability map instead

Use 3dresample -orient AIL -input dset -prefix output instead of -master dset -dxyz

Deoblique FLAIR before anything else (3dWarp -oblique2card -prefix T2SPACEFLAIRvb17bw651subj_card.nii T2SPACEFLAIRvb17bw651651subj.nii)

Aligning LST output to anat_w_skull_warped+tlrc

Putting LST output into TLRC space (@auto_tlrc -apar anat_w_skull_warped+tlrc -input ples_lpa_mrT2SPACEFLAIRvb17bw651subj.nii -suffix ples2tlrc)

…and some more headache

It seems you’re pretty confused about what all these commands do, and I’m not sure what it is you want to do really. Alignment isn’t the same thing as resampling. I think what you want to do is compute an alignment between one dataset and another and then apply that alignment to an ROI. It is almost never a good idea or needed to compute alignment only for a mask to a dataset. Any specific orientation on a dataset isn’t typically required. A quick overview of some of the available commands:

3dresample - interpolates to a new grid possibly with different orientation or voxel size
3dWarp - apply an affine warp transformation either from a text file or in the header of the dataset (as in obliquing/deobliquing)
3dAllineate - compute affine alignment, apply affine warp transformation, and may resample to a different grid too.
3dvolreg - compute rigid transformations within same grid and orientation using weighted least squares cost function
3dWarpDrive - compute affine transformation alignment using weighted least squares cost function
align_epi_anat.py - align two datasets - “child” datasets may be transformed similarly to the input datasets. This python script calls 3dAllineate for computation and application of the transformations.

Considering computing the transformation with 3dAllineate or align_epi_anat.py and applying that transformation with align_epi_anat.py. If you run into problems, PM me for instructions on uploading data, and I’ll try to help.