mesh2nii
tit.tools.mesh2nii ¶
Mesh-to-NIfTI conversion using the SimNIBS Python API.
Provides callable functions that wrap simnibs.transformations so the
simulator pipeline can convert meshes without shelling out to bash scripts.
Public API¶
msh_to_nifti – single mesh → subject-space NIfTI msh_to_mni – single mesh → MNI-space NIfTI convert_mesh_dir – batch-convert every mesh in a directory
msh_to_nifti ¶
msh_to_nifti(mesh_path: str, m2m_dir: str, output_path: str, fields: list[str] | None = None) -> None
Convert a mesh file to subject-space NIfTI.
Parameters¶
mesh_path : str
Path to the .msh file.
m2m_dir : str
Path to the m2m_{subject} directory (used as reference grid).
output_path : str
Output file prefix. SimNIBS appends the field name
(e.g. prefix_magnE.nii.gz).
fields : list[str] | None
If given, only these fields are written. Otherwise all fields in the
mesh are converted.
Source code in tit/tools/mesh2nii.py
msh_to_mni ¶
Convert a mesh file to MNI-space NIfTI.
Parameters¶
mesh_path : str
Path to the .msh file.
m2m_dir : str
Path to the m2m_{subject} directory.
output_path : str
Output file prefix. SimNIBS appends the field name
(e.g. prefix_magnE.nii.gz).
fields : list[str] | None
If given, only these fields are written.
Source code in tit/tools/mesh2nii.py
convert_mesh_dir ¶
convert_mesh_dir(mesh_dir: str, output_dir: str, m2m_dir: str, fields: list[str] | None = None, skip_patterns: list[str] | None = None) -> None
Batch-convert every .msh file in mesh_dir to NIfTI.
For each mesh two NIfTI sets are produced:
{basename}_subject_{field}.nii.gz– subject space{basename}_MNI_{field}.nii.gz– MNI space
Parameters¶
mesh_dir : str
Directory containing .msh files.
output_dir : str
Where the NIfTI files are written.
m2m_dir : str
Path to the m2m_{subject} directory.
fields : list[str] | None
If given, only these fields are converted.
skip_patterns : list[str] | None
Basenames containing any of these substrings are skipped.
Defaults to ["normal"] (surface-only meshes have no volume
elements).