Nibabel-Data Extraction from nii.gz file Python

Hi everyone,

I’m new to using Nibabel on Python but I have a bunch of T1w, T2w and BOLD scans in BIDS format. I am trying to extract information from the .nii.gz file and create a CSV dashboard with the information below. I am looking to extract the following from each nii.gz file and have it as a dashboard for each file.

-Data source, dim1, dim2, dim3, AcquisitionMatrixPE, ImageType, ImageTypeText, EchoTime, RepetitionTime, SeriesDescription, SeriesNumber.

Note: Not all nii.gz files have ImageTypeText so I would only be extracting it for the nii.gz files that do have that field present.

Does anybody have a code on how to extract these from the nii.gz file, or some help.

I read the header on python but the nii.gz file header does not contain the information above that I am looking to extract.

Thanks for you help.

–Subbi M.