This project provides a Python script to convert NIfTI (.nii or .nii.gz) files into GIFTI (.gii) files for both left and right pial surfaces from the fsaverage surface included in nilearn. The script is a wrapper for Nilearn and Nibabel functions and outputs the GIFTI files in the same directory as the input NIfTI file, using the same base filename. The .gii file can then be opened with other software (i.e. surfice) for plotting
You can use the script in two ways:
- Command Line Interface (CLI): Provide the input file as an argument to convert directly from the terminal.
- Graphical Dialog: Run the script without arguments to open a file dialog for interactive file selection.
Install the required dependencies with:
pip install -r requirements.txt- nilearn
- nibabel
- numpy
To convert a .nii or .nii.gz file to .gii files from the terminal:
python convert_nii_to_gii.py <input_file.nii[.gz]><input_file.nii[.gz]>: Path to your NIfTI file.
The output files will be named after the input file, with _left.gii and _right.gii suffixes, and saved in the same directory.
To use the graphical interface, run the script without any arguments:
python convert_nii_to_gii.pyA dialog box will appear, allowing you to select the input file interactively.
The script generates two GIFTI files in the same directory as the input NIfTI file:
<input_file>_left.gii(left pial surface)<input_file>_right.gii(right pial surface)
Convert both surfaces and use default output names:
python convert_nii_to_gii.py input.nii.gzThis will create input_left.gii and input_right.gii in the same folder as the input