Reorganizing NifTI to BIDS

Hi everyone.

I have a set of DCM files that have already been converted with dcm2nii. Is there a standardized script available that then reorganizes those into a BIDS format?

Thanks.

Hey @MunamWasi,

heudiconv and BidsConverter should be very helpful!

HTH, best, Peer

If you still have access to DICOMs I would recommend converting them again using one of the solutions listed here: Convert data to BIDS format This will allow you to automatically extract much more metadata than is present in your NIfTIs.

Otherwise I don’t know of an existing script to do that for any arbitrary input organization of NIfTIs, but writing such script tailored to your input organization should be straightforward.

Hi @PeerHerholz,

Thanks for the suggestions. I’m looking through how those works, but, my problem is that I no longer have the DICOM files available. Is there a workaround step that I should be looking at?

Thanks.

Hi @ChrisGorgolewski,

I appreciate your help here.

I do not have the original DICOMs anymore. Is there anything that I should look out for considering that I will be missing a lot of metadata?

Thanks.

Just try to dig up the scanning protocols to confirm that the RepetitionTime is correct (this one is stored in the nifti headers, but some old converters did not save it correctly) and optionally try to figure out what is the SliceTiming. Good luck!

Hey @MunamWasi,

sorry for the late reply. I can’t think of any predefined workaround step right now.
But, this is what @ChrisGorgolewski mentioned: a small script that reorganizes your data
tailored to your structure should be straightforward and done quickly.

Best, Peer

Hi @MunamWasi,
Was reorganizing NII to BIDS successful? if yes, could you please share your experience?

Hello @Relyativist. I ended up using a tool called MRIcroGL. I was able to do both my pre-processing and was able to do the BIDS conversion successfully through that.

@MunamWasi thank for your reply. But, i there is no such option in MRIcroGL as convert to BIDS, it only supports dcm2niix as i remember.

Has anyone figured out a way to convert .nii.gz to BIDS sans the raw data?

Hi @Teodorast, have the compressed nifti images been generated by dcm2niix?

unfortunately not, they are templates generated by recent studies. However, I am now trying to transform the nifti files back into DICOM files and use dcm2niix to get them into BIDS format.

I’m unsure if you can revert back to DICOM format from nifti, but it might also be worth seeing if the owner(s) will share the DICOMS with you or convert them to nifti/json file format (via dcm2niix) and share those with you

Ah yes, that’s another option. I will try to use GitHub - biolab-unige/nifti2dicom: Convert 3D NIfTI images (and other formats supported by ITK) to DIC and report back if it worked.

1 Like

@Teodorast the NIfTI format images are very simple, and contain very little sequence information. On the other hand, DICOM images are very complex, and different vendors have interpreted the standard differently. The rationale of the BIDS JSON sidecar is that it contains information that is not included in the NIfTI header in a simple human readable text format in a vendor agnostic manner. By design, the information in the BIDS sidecar is mutually exclusive of the NIfTI header.

Therefore, while it would be possible to convert a NIfTI to a DICOM image, the image would be very impoverished with regards to sequence details. Indeed, the image would lack the required Type 1 tags required for the MR modality. So the resulting image would be a technically invalid DICOM image or it would need to be saved as the OT (other) modality type. While a tool like dcm2niix could convert such an image to NIfTI, it would not include any sequence information and the BIDS sidecar would not contain any meaningful information.

If you only have NIfTI images, without the relevant BIDS sidecar or originating DICOM images, you do not have sufficient information for thorough data processing. This image data would not be of archival quality and would be insufficient for automated processing. Your best bet is to get a sequence PDF and manually translate the values to a BIDS sidecar for each sequence. This can be challenging, as different manufacturers use different terminology from each other and the BIDS standard.

3 Likes

Thank you for the detailed response @Chris_Rorden. The only reason I am trying to revert from nifti back to DICOM is so that I extract the JSON sidecar (so it’s in BIDS format, so I can upload it into TemplateFlow, so I can use it in fmriprep). But after using xmedcon [https://xmedcon.sourceforge.io/] to achieve this, I can see that there is almost 0 relevant information in the resulting JSON file.

I have resorted to manually building the JSON file with the information provided on each template’s information page.

Hi @Teodorast I also am in the same boat and only have access to the .nii files. Did you manage to create a script that reformats nifti to BIDS structure?

If yes, would you mind sharing your script?

Thanks.

–Subbi M.