AFNI Message Board

Dear AFNI users-

We are very pleased to announce that the new AFNI Message Board framework is up! Please join us at:

https://discuss.afni.nimh.nih.gov

Existing user accounts have been migrated, so returning users can login by requesting a password reset. New users can create accounts, as well, through a standard account creation process. Please note that these setup emails might initially go to spam folders (esp. for NIH users!), so please check those locations in the beginning.

The current Message Board discussion threads have been migrated to the new framework. The current Message Board will remain visible, but read-only, for a little while.

Sincerely, AFNI HQ

History of AFNI updates  

|
April 10, 2023 07:59AM
Hi,

this is going to be a bit complicated, but I try to describe my problem as simple as possible.

I extracted voxel-based time-series from AFNI functional scans (3x3x3 mm voxels) using 3dmaskdump. Subsequently, I loaded the extracted time-series into Python, and computed one measurement for each voxel (meaning I get one value per voxel, such as 7.54 or 2.13).

Furthermore, I also extracted the 3D coordinates of the template I am using (Schaefer-Yeo-AFNI-2021 Atlas 1000 parcels version) after resampling this atlas to 3x3x3 mm voxels with 3dresample, so that the anatomical voxel size matches the functional voxel size. Here is the 3dresample code for the atlas:

3dresample \
-input /volumes.../Schaefer_7N_1000_ribbon.nii.gz \ # AFNI atlas mentioned above
-master /volumes/errts.Subject1.anaticor+tlrc \ # Preprocessed functional run
-prefix Resample_Yeo7N_1000ribbon.nii

Here is the code that I used to extract the voxel-based coordinates after resampling the atlas:

3dmaskdump \
-mask $network.nii \ # Was part of a for loop to select several networks
-noijk \
-xyz \
-quiet \
Resample_Yeo7N_1000ribbon.nii \ # The 3x3x3 mm resampled Schaefer-Yeo-AFNI-2021 Atlas 1000 parcels version
> Cor_${network}.1D # Save xyz coordinates to .1D files

Next, I computed a measurement in Python, loading the 3dmaskdump extracted voxel time-series into Python.
Furthermore, I also loaded the the resampled atlas 3D coordinates into Python.
Using Python, I then saved the results in the following format, where the results are saved row-wise in a .1D file

x y z measurement_result

This means that the first index is the x, the second the y, and the third the z 3D space voxel coordinate. Finally, the fourth index is the result of the measurement.
Only spaces were added between x y z and the voxel value, nothing else.

I then compared the coordinates extracted by 3dmaskdump and the voxel coordinates + result value by Python. Both files exactly match, meaning that the voxel coordinates (xyz) are exactly the same, from the first to the last voxel.

Next, I wanted to transform my voxel coordinate plus measurement result .1D files into NIfTI files. Therefore, I used 3dUndump. I loaded the .1D files saved by Python (the previous step above) and wanted to save those .1D files as NIfTI files using 3dundump Here is my code:

3dUndump \
-xyz \
-prefix someprefix \
-master Resample_Yeo7N_1000ribbon.nii \  # The 3x3x3 mm resampled Schaefer-Yeo-AFNI-2021 Atlas 1000 parcels version
-mask $dir_rois/$network.nii \ # The specific networks I chose (using a for loop here)
acw_${network}.1D # The input files, again part of a for loop

Now, in this step using 3dUndump comes the problem. For many (although not for all) voxels AFNI prints the following error:

Quote
*+ WARNING: File /volumes/.../acw_Global.1D line 14331: y coord=-97.5 is outside -96.003 .. 132.003
*+ WARNING: File/volumes/.../acw_Global.1D line 14332: y coord=-97.5 is outside -96.003 .. 132.003
*+ WARNING: /volumes/.../acw_Global.1D line 14333: y coord=-97.5 is outside -96.003 .. 132.003
*+ WARNING: /volumes/.../acw_Global.1D line 14334: y coord=-97.5 is outside -96.003 .. 132.003
*+ WARNING: /volumes/.../acw_Global.1D line 14335: y coord=-97.5 is outside -96.003 .. 132.003
*+ WARNING: /volumes/.../acw_Global.1D line 14990: y coord=-97.5 is outside -96.003 .. 132.003


I shortened AFNI’s output above. Loading the resulting NIfTI file of 3dUndump into AFNI or MRIcroGL looks ok, I do not see any flaws there.
However, when I plot those NIfTI result by 3dUndump via nilearn (Python), I can see that especially the posterior part of the brain seems to lack any values or is not plotted, it just plots a pure greenish area, the real values are somehow not placed on the brain’s surface.

I am wondering if that problem is related to the error by 3dUndump above and not to Python itself. I assume that the voxels’ affected by the WARNINGs above are somehow displaced in 3D space, meaning that nilearn in Python cannot properly find and place all voxels within the NIfTI file produced by AFNI’s 3dUndump.

----------------
The attached picture shows the result of the nilearn plot that loads the NIfTI file produced by 3dUndump. The picture also shows the result of the same brain when loading the voxel coordinates plus my measurement results into Python, and plotting the same brain as 3D scatter plot (instead of using the AFNI’s 3dUndump created NIfTI file).

You can clearly see tha the nilearn brain (that is using the NIfTI output by AFNI’s 3dUndump) lacks ~50% of data for the brain surface, where, instead, it only shows a massively green surface which is clearly wrong. At the same time, the 3d scatter plot that is not using AFNI’s 3dUndump shows a perfectly fine result.

Can you guys detect a mistake in my AFNI scripts shown above? What am I doing wrong in the AFNI-related scripts so that 3dUndump prints warnings for many voxels that are out of space?
Attachments:
open | download - 123.png (1001.4 KB)
Subject Author Posted

Extracting voxel-wise data with 3dmaskdump and recombing it with 3dUndump Attachments

Philipp April 10, 2023 07:59AM

Re: Extracting voxel-wise data with 3dmaskdump and recombing it with 3dUndump Attachments

Philipp April 10, 2023 08:13AM

Re: Extracting voxel-wise data with 3dmaskdump and recombing it with 3dUndump

ptaylor April 10, 2023 09:23AM

Re: Extracting voxel-wise data with 3dmaskdump and recombing it with 3dUndump Attachments

Philipp April 10, 2023 12:53PM

Re: Extracting voxel-wise data with 3dmaskdump and recombing it with 3dUndump

ptaylor April 10, 2023 03:18PM

Re: Extracting voxel-wise data with 3dmaskdump and recombing it with 3dUndump

Philipp April 10, 2023 03:20PM

Re: Extracting voxel-wise data with 3dmaskdump and recombing it with 3dUndump

Philipp April 10, 2023 03:31PM

Re: Extracting voxel-wise data with 3dmaskdump and recombing it with 3dUndump

ptaylor April 10, 2023 03:38PM

Re: Extracting voxel-wise data with 3dmaskdump and recombing it with 3dUndump

Philipp April 10, 2023 03:47PM

Re: Extracting voxel-wise data with 3dmaskdump and recombing it with 3dUndump

ptaylor April 10, 2023 04:56PM

Re: Extracting voxel-wise data with 3dmaskdump and recombing it with 3dUndump

Philipp April 10, 2023 05:11PM

Re: Extracting voxel-wise data with 3dmaskdump and recombing it with 3dUndump

ptaylor April 10, 2023 05:29PM

Re: Extracting voxel-wise data with 3dmaskdump and recombing it with 3dUndump

Philipp April 10, 2023 05:40PM

Re: Extracting voxel-wise data with 3dmaskdump and recombing it with 3dUndump

Philipp April 10, 2023 05:47PM

Re: Extracting voxel-wise data with 3dmaskdump and recombing it with 3dUndump

Philipp April 11, 2023 04:01AM

Re: Extracting voxel-wise data with 3dmaskdump and recombing it with 3dUndump

ptaylor April 11, 2023 09:54AM

Re: Extracting voxel-wise data with 3dmaskdump and recombing it with 3dUndump

Philipp April 11, 2023 02:14PM

Re: Extracting voxel-wise data with 3dmaskdump and recombing it with 3dUndump

rick reynolds April 18, 2023 04:12PM