Open Zhangzhixiang-laugh opened 1 month ago
Sorry for the oversight! I believe I created the Schaefer1000_3mm.nii.gz
file offline by using AFNI's 3dresample
with the 1 mm resolution Schaefer atlas as -input
and one of the functional images from the Narratives dataset as -master
, with -rmode NN
i.e. nearest-neighbor resampling. In other words, the Schaefer1000_3mm.nii.gz
is a version of the original Schaefer atlas resampled to the grid and resolution of the BOLD data.
Sorry for the oversight! I believe I created the
Schaefer1000_3mm.nii.gz
file offline by using AFNI's3dresample
with the 1 mm resolution Schaefer atlas as-input
and one of the functional images from the Narratives dataset as-master
, with-rmode NN
i.e. nearest-neighbor resampling. In other words, theSchaefer1000_3mm.nii.gz
is a version of the original Schaefer atlas resampled to the grid and resolution of the BOLD data.
Thank you for your reply, I have solved this issue with python tools. The reference code is as follows:
import nibabel as nib
import numpy as np
from scipy.ndimage import zoom
def resample_nii_to_target_resolution(input_nii_path,standard_nii_path, output_nii_path):
# Load the input and target NIfTI file
img_src = nib.load(input_nii_path)
src = img_src.get_fdata()
img_std = nib.load(standard_nii_path)
std = img_std.get_fdata()
# Ensure data is in appropriate format for NIfTI
src = src.astype(np.int16) # Use a smaller integer type to save space
std = std.astype(np.int16) # Use a smaller integer type to save space
# Get the original and target resolution from the affine matrix
original_affine = img_src.affine
original_resolution = np.abs(original_affine[0, 0])
standard_affine = img_std.affine
standard_resolution = np.abs(standard_affine[0, 0])
# Calculate the resampling factor
resampling_factor = original_resolution / standard_resolution
# Resample the data using nearest neighbor interpolation
resampled_data = zoom(src, zoom=(resampling_factor, resampling_factor, resampling_factor), order=0)
# Ensure resampled data is in appropriate format
resampled_data = resampled_data.astype(np.int16) # Use a smaller integer type to save space
# Create a new affine matrix for the target resolution
new_affine = np.copy(original_affine)
new_affine[:3, :3] /= resampling_factor
# Create a new NIfTI image with the resampled data
resampled_img = nib.Nifti1Image(resampled_data, affine=new_affine)
# Save the resampled image to the output path with maximum compression
nib.save(resampled_img, output_nii_path)
# Example usage
input_nii_path = '/mnt/d/github projects/bert-brains-master/data/schaefer1000MNI_1mm.nii.gz' # Replace with the path to your Schaefer NIfTI file
standard_nii_path = '/mnt/d/github projects/bert-brains-master/data/black_data/sub-127.nii.gz' # Standard file path
output_nii_path = '/mnt/d/github projects/bert-brains-master/data/schaefer1000MNI_3mm.nii.gz' # Output file path
resample_nii_to_target_resolution(input_nii_path, standard_nii_path,output_nii_path)
Through browsing and searching a lot of literature and Internet materials, I did not find any data on Schaefer1000_3mm.nii.gz (only found Schaefer1000_1mm.nii.gz and Schaefer1000_2mm.nii.gz). At last but not least, thanks for providing Schaefer1000_3mm.nii.gz!!! References: 1.https://github.com/ThomasYeoLab/CBIG/tree/master/stable_projects/brain_parcellation/Schaefer2018_LocalGlobal/Parcellations/MNI 2.https://www.ncbi.nlm.nih.gov/pmc/articles/PMC6095216/pdf/bhx179.pdf