### Generate Surface Data from FsLabel Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_label/struct.FsLabel.html Creates a data vector for the entire surface based on the label. Vertices in the label get a specified value, while others get `not_in_label_value`. Panics if num_surface_verts is smaller than the max index stored in the label. ```rust pub fn as_surface_data( &self, num_surface_verts: usize, not_in_label_value: f32, ) -> Vec ``` -------------------------------- ### Move BrainMesh to Origin Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_surface/struct.BrainMesh.html Moves the mesh to a new location by adding an offset to each vertex. This example demonstrates moving the mesh to the origin (0,0,0) by calculating its center and then applying the negative of that center as the offset. ```rust let mut mesh = neuroformats::BrainMesh::from_obj_file("resources/mesh/cube.obj").unwrap(); let (cx, cy, cz) = mesh.center().unwrap(); mesh.move_to((cx, cy, cz)); ``` -------------------------------- ### Compute Vox2RAS Matrix Example Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_mgh/struct.FsMghHeader.html Demonstrates how to compute the vox2ras matrix from an MGH header. This matrix can be used to convert voxel coordinates to RAS (Right-Anterior-Superior) coordinates. ```rust use ndarray::{Array1, array}; let mgh = neuroformats::read_mgh("/path/to/subjects_dir/subject1/mri/brain.mgz").unwrap(); let vox2ras = mgh.vox2ras().unwrap(); let my_voxel_ijk : Array1 = array![32.0, 32.0, 32.0, 1.0]; // actually integers, but we use float for matrix multiplication. The final 1 is due to homegenous coords. let my_voxel_ras = vox2ras.dot(&my_voxel_ijk); ``` -------------------------------- ### from_reader Function Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_annot/struct.FsAnnotColortable.html Reads a colortable in format version 2 from a given reader. The reader must be positioned at the start of the colortable data. ```APIDOC ## impl FsAnnotColortable ### pub fn from_reader(input: &mut S) -> Result where S: BufRead, Reads a colortable in format version 2 from a reader. The reader must be at the start position of the colortable. ``` -------------------------------- ### Read Colortable from Reader Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_annot/struct.FsAnnotColortable.html Reads a colortable in format version 2 from a BufRead source. The reader must be positioned at the start of the colortable data. ```rust pub fn from_reader(input: &mut S) -> Result where S: BufRead, ``` -------------------------------- ### Get Vertex Colors with Alpha Channel Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_annot/struct.FsAnnot.html Generates RGBA color values for each vertex. The `unmatched_region_index` parameter specifies the color for vertices not matching any defined region. Panics if the index is out of bounds. ```rust let annot = neuroformats::read_annot("/path/to/subjects_dir/subject1/label/lh.aparc.annot").unwrap(); let col_rgba = annot.vertex_colors(true, 0); assert_eq!(col_rgba.len(), annot.vertex_indices.len() * 4); ``` -------------------------------- ### type_id Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_annot/struct.FsAnnot.html Gets the `TypeId` of `self`. ```APIDOC ## type_id ### Description Gets the `TypeId` of `self`. ### Signature `fn type_id(&self) -> TypeId` ``` -------------------------------- ### Generic VZip Implementation Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_annot/struct.FsAnnotColorRegion.html Zips multiple lanes of data together. ```rust fn vzip(self) -> V ``` -------------------------------- ### clone_to_uninit Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_annot/struct.FsAnnot.html Performs copy-assignment from `self` to `dest`. This is a nightly-only experimental API. ```APIDOC ## clone_to_uninit ### Description Performs copy-assignment from `self` to `dest`. ### Note This is a nightly-only experimental API. ### Signature `unsafe fn clone_to_uninit(&self, dest: *mut u8)` ``` -------------------------------- ### FsMgh::dim Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_mgh/struct.FsMgh.html Gets the dimensions of the MGH data. ```APIDOC ## pub fn dim(&self) -> [usize; 4] ### Description Get dimensions of the MGH data. ### Returns - **[usize; 4]** - An array of 4 usize values representing the dimensions. ``` -------------------------------- ### try_into Method Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_surface/struct.FsSurface.html Performs the conversion for FsSurface, returning a Result. ```APIDOC #### fn try_into(self) -> Result>::Error> Performs the conversion. ``` -------------------------------- ### into Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_annot/struct.FsAnnot.html Calls `U::from(self)`. This conversion is determined by the implementation of `From for U`. ```APIDOC ## into ### Description Calls `U::from(self)`. ### Note This conversion is whatever the implementation of `From for U` chooses to do. ### Signature `fn into(self) -> U` ``` -------------------------------- ### Generic Any Implementation Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_annot/struct.FsAnnotColorRegion.html Provides a way to get the `TypeId` of any type `T` that is `'static` and `?Sized`. ```rust fn type_id(&self) -> TypeId ``` -------------------------------- ### FsLabel Methods Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_label/struct.FsLabel.html Methods available for the FsLabel struct. ```APIDOC ## pub fn is_binary(&self) -> bool ### Description Determine whether this is a binary label. A binary label assigns the same value (typically `0.0`) to all its vertices. Such a label is typically used to define a region of some sort, e.g., a single brain region extracted from a brain surface parcellation (see FsAnnot). Whether or not the label is intended as a binary inside/outside region definition cannot be known, so treat the return value as an educated guess. ### Panics * If the label is empty, i.e., contains no values. ### Method `is_binary` ``` ```APIDOC ## pub fn is_surface_vertex_in_label(&self, num_surface_verts: usize) -> Vec ### Description Determine for each vertex whether it is part of this label. This is a simple convenience function. Note that you need to supply the total number of vertices of the respective surface, as that number is not stored in the label. ### Panics * If `num_surface_verts` is smaller than the max index stored in the label. If this happens, the label cannot belong to the respective surface. ### Method `is_surface_vertex_in_label` ``` ```APIDOC ## pub fn as_surface_data(&self, num_surface_verts: usize, not_in_label_value: f32) -> Vec ### Description Generate data for the whole surface from this label. This is a simple convenience function that creates a data vector with the specified length and fills it with the label value for vertices which are part of this label and sets the rest to the `not_in_label_value` (typically `f32::NAN`). ### Panics * If `num_surface_verts` is smaller than the max index stored in the label. If this happens, the label cannot belong to the respective surface. ### Method `as_surface_data` ``` -------------------------------- ### FsAnnot::num_regions Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_annot/struct.FsAnnot.html Gets the total number of regions present in the FsAnnot struct or its associated colortable. ```APIDOC ## pub fn num_regions(&self) -> usize Get the number of regions contained in the `FsAnnot` struct, or its `FsAnnotColortable`. ### Examples ``` let annot = neuroformats::read_annot("/path/to/subjects_dir/subject1/label/lh.aparc.annot").unwrap(); annot.num_regions(); ``` ``` -------------------------------- ### FsLabelVertex PartialEq Implementation Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_label/struct.FsLabelVertex.html Provides equality comparison for FsLabelVertex instances. ```APIDOC ### impl PartialEq for FsLabelVertex #### fn eq(&self, other: &FsLabelVertex) -> bool Tests for `self` and `other` values to be equal, and is used by `==`. ``` -------------------------------- ### Get Owned Type Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_mgh/struct.FsMgh.html Defines the `Owned` associated type for the `ToOwned` trait, which is typically the type itself. ```rust type Owned = T ``` -------------------------------- ### Get MGH Data Dimensions Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_mgh/struct.FsMgh.html Retrieves the dimensions of the MGH data as a [usize; 4] array. ```rust pub fn dim(&self) -> [usize; 4] ``` -------------------------------- ### VZip Implementation Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_surface/struct.FsSurface.html Implementation of VZip for T where V meets the MultiLane trait bound. ```APIDOC ### impl VZip for T where V: MultiLane, #### fn vzip(self) -> V ``` -------------------------------- ### FsCurvHeader::from_reader Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_curv/struct.FsCurvHeader.html Reads a Curv header from a given byte stream, assuming the stream is positioned at the start of the header. ```APIDOC ## pub fn from_reader(input: S) -> Result where S: BufRead, ### Description Read a Curv header from the given byte stream. It is assumed that the input is currently at the start of the Curv header. ### Parameters - `input`: S - A type that implements the BufRead trait. ``` -------------------------------- ### Nightly-Only clone_to_uninit Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_annot/struct.FsAnnotColorRegion.html An experimental nightly-only API to perform copy-assignment from `self` to an uninitialized destination. ```rust unsafe fn clone_to_uninit(&self, dest: *mut u8) ``` -------------------------------- ### Get Region Names for All Vertices Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_annot/struct.FsAnnot.html Retrieves a list of region names corresponding to each vertex in the FsAnnot struct, in the order they appear. ```rust let annot = neuroformats::read_annot("/path/to/subjects_dir/subject1/label/lh.aparc.annot").unwrap(); annot.vertex_regions(); ``` -------------------------------- ### PartialEq Implementation for FsLabelVertex Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_label/struct.FsLabelVertex.html Provides methods for comparing two FsLabelVertex instances for equality or inequality. ```rust fn eq(&self, other: &FsLabelVertex) -> bool ``` ```rust fn ne(&self, other: &Rhs) -> bool ``` -------------------------------- ### Read FsCurvHeader from Byte Stream Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_curv/struct.FsCurvHeader.html Reads a Curv header from a byte stream. Assumes the stream is positioned at the start of the header. ```rust pub fn from_reader(input: S) -> Result where S: BufRead, ``` -------------------------------- ### try_from Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_annot/struct.FsAnnot.html Performs the conversion from `U` to `T`. ```APIDOC ## try_from ### Description Performs the conversion. ### Signature `fn try_from(value: U) -> Result>::Error>` ``` -------------------------------- ### vzip Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_annot/struct.FsAnnot.html Applies the `VZip` operation. ```APIDOC ## vzip ### Description Applies the `VZip` operation. ### Signature `fn vzip(self) -> V` ``` -------------------------------- ### Read FsSurface from File Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_surface/struct.FsSurface.html Reads an FsSurface instance from a file in FreeSurfer surf format. Requires a path that can be referenced. ```rust pub fn from_file + Copy>(path: P) -> Result ``` -------------------------------- ### Get Region Names from FsAnnot Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_annot/struct.FsAnnot.html Retrieves a list of all unique brain region names present in the FsAnnot struct. This is useful for understanding the parcellation scheme. ```rust let annot = neuroformats::read_annot("/path/to/subjects_dir/subject1/label/lh.aparc.annot").unwrap(); annot.regions(); ``` -------------------------------- ### from Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_annot/struct.FsAnnot.html Returns the argument unchanged. ```APIDOC ## from ### Description Returns the argument unchanged. ### Signature `fn from(t: T) -> T` ``` -------------------------------- ### Generic From Implementation Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_annot/struct.FsAnnotColorRegion.html A trivial conversion that returns the argument unchanged. ```rust fn from(t: T) -> T ``` -------------------------------- ### Get Number of Regions in FsAnnot Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_annot/struct.FsAnnot.html Returns the total count of distinct brain regions defined in the FsAnnot struct or its associated colortable. Use this to quickly ascertain the complexity of the parcellation. ```rust let annot = neuroformats::read_annot("/path/to/subjects_dir/subject1/label/lh.aparc.annot").unwrap(); annot.num_regions(); ``` -------------------------------- ### from_obj_file Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_surface/struct.BrainMesh.html Reads a brain mesh from a Wavefront object format (.obj) file. ```APIDOC ## pub fn from_obj_file>(path: P) -> Result Read a brain mesh from a Wavefront object format (.obj) mesh file. ### Examples ```rust let mesh = neuroformats::BrainMesh::from_obj_file("resources/mesh/cube.obj").unwrap(); assert_eq!(24, mesh.vertices.len()); ``` ``` -------------------------------- ### Get Vertex Colors without Alpha Channel Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_annot/struct.FsAnnot.html Generates RGB color values for each vertex. The `unmatched_region_index` parameter specifies the color for vertices not matching any defined region. Panics if the index is out of bounds. ```rust let annot = neuroformats::read_annot("/path/to/subjects_dir/subject1/label/lh.aparc.annot").unwrap(); let col_rgb = annot.vertex_colors(false, 0); assert_eq!(col_rgb.len(), annot.vertex_indices.len() * 3); ``` -------------------------------- ### Clone Implementation for FsAnnotColorRegion Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_annot/struct.FsAnnotColorRegion.html Provides methods to duplicate FsAnnotColorRegion instances. `clone` creates a new instance, while `clone_from` performs copy-assignment. ```rust fn clone(&self) -> FsAnnotColorRegion ``` ```rust fn clone_from(&mut self, source: &Self) ``` -------------------------------- ### Get Vertices for a Specific Region Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_annot/struct.FsAnnot.html Finds all vertex indices belonging to a specified brain region. If a region has no assigned vertices, an empty vector is returned. This method panics if the region name is not found. ```rust let annot = neuroformats::read_annot("/path/to/subjects_dir/subject1/label/lh.aparc.annot").unwrap(); annot.region_vertices(String::from("bankssts")); ``` -------------------------------- ### try_into Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_annot/struct.FsAnnot.html Performs the conversion from `T` to `U`. ```APIDOC ## try_into ### Description Performs the conversion. ### Signature `fn try_into(self) -> Result>::Error>` ``` -------------------------------- ### clone_into Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_annot/struct.FsAnnot.html Uses borrowed data to replace owned data, usually by cloning. ```APIDOC ## clone_into ### Description Uses borrowed data to replace owned data, usually by cloning. ### Signature `fn clone_into(&self, target: &mut T)` ``` -------------------------------- ### clone_into Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_mgh/struct.FsMghHeader.html Clones borrowed data into the target, replacing owned data. ```APIDOC ## fn clone_into(&self, target: &mut T) ### Description Uses borrowed data to replace owned data, usually by cloning. ### Parameters - **target** (&mut T) - The mutable reference to the target where the data will be cloned. ``` -------------------------------- ### Read a FreeSurfer label file Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_label/fn.read_label.html Reads a label file and prints information about the first vertex. Ensure the path points to a valid FreeSurfer label file. ```rust let label = neuroformats::read_label("/path/to/subjects_dir/subject1/label/lh.entorhinal_exvivo.label").unwrap(); let first = &label.vertexes[0]; println!("Vertex #{} has coordinates {} {} {} and is assigned value {}.", first.index, first.coord1, first.coord2, first.coord3, first.value); ``` -------------------------------- ### FsSurface::from_file Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_surface/struct.FsSurface.html Reads an FsSurface instance from a file in FreeSurfer surf format. ```APIDOC ## FsSurface::from_file ### Description Reads an FsSurface instance from a file in FreeSurfer surf format. ### Method Signature `pub fn from_file + Copy>(path: P) -> Result` ### Parameters * `path` - A type that can be referenced as a Path and copied. ``` -------------------------------- ### Clone Implementation for FsLabelVertex Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_label/struct.FsLabelVertex.html Provides methods for creating a duplicate of an FsLabelVertex or performing copy-assignment from another FsLabelVertex. ```rust fn clone(&self) -> FsLabelVertex ``` ```rust fn clone_from(&mut self, source: &Self) ``` -------------------------------- ### PartialEq Implementation for FsAnnotColortable Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_annot/struct.FsAnnotColortable.html Provides methods for comparing FsAnnotColortable instances for equality. ```rust fn eq(&self, other: &FsAnnotColortable) -> bool ``` ```rust fn ne(&self, other: &Rhs) -> bool ``` -------------------------------- ### write_label Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_label/index.html Writes an FsLabel struct to a new file. ```APIDOC ## write_label ### Description Write an FsLabel struct to a new file. ### Parameters * **label** (FsLabel) - Required - The FsLabel struct to write. * **file_path** (PathBuf) - Required - The path to the output file. ### Returns * Result<(), std::io::Error> - Ok(()) on success, or an std::io::Error on failure. ``` -------------------------------- ### PartialEq Implementation for FsAnnotColorRegion Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_annot/struct.FsAnnotColorRegion.html Enables comparison of FsAnnotColorRegion instances for equality using `==` and inequality using `!=`. ```rust fn eq(&self, other: &FsAnnotColorRegion) -> bool ``` ```rust fn ne(&self, other: &Rhs) -> bool ``` -------------------------------- ### Clone Implementation for FsMghData Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_mgh/struct.FsMghData.html Provides methods for cloning FsMghData instances, allowing for duplication and copy-assignment. ```APIDOC ### impl Clone for FsMghData #### fn clone(&self) -> FsMghData Returns a duplicate of the value. #### fn clone_from(&mut self, source: &Self) Performs copy-assignment from `source`. ``` -------------------------------- ### fs_surface Module Functions Source: https://docs.rs/neuroformats/0.3.0/neuroformats/index.html Functions for managing FreeSurfer brain surface meshes in binary ‘surf’ files. ```APIDOC ## fs_surface Module ### `coord_center` Calculates the center coordinate of a surface. ### `coord_extrema` Calculates the extrema coordinates of a surface. ### `read_surf` Reads a FreeSurfer surface file. ### `write_surf` Writes data to a FreeSurfer surface file. ### `BrainMesh` Represents a brain mesh. ### `FsSurface` Represents a FreeSurfer surface file. ### `FsSurfaceHeader` Represents the header of a FreeSurfer surface file. ``` -------------------------------- ### write_surf Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_surface/fn.write_surf.html Writes an FsSurface struct to a file in FreeSurfer surf format. ```APIDOC ## write_surf ### Description Write an FsSurface struct to a file in FreeSurfer surf format. ### Signature ```rust pub fn write_surf + Copy>( path: P, surf: &FsSurface, ) -> Result<()> ``` ### Parameters * `path`: A type that implements `AsRef` and `Copy`, representing the file path to write to. * `surf`: A reference to an `FsSurface` struct to be written. ``` -------------------------------- ### FsLabelVertex FromStr Implementation Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_label/struct.FsLabelVertex.html Allows parsing a string into an FsLabelVertex, with associated error type. ```APIDOC ### impl FromStr for FsLabelVertex #### type Err = NeuroformatsError #### fn from_str(s: &str) -> Result Parses a string `s` to return a value of this type. ``` -------------------------------- ### write_label Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_label/fn.write_label.html Writes an FsLabel struct to a new file at the specified path. ```APIDOC ## write_label ### Description Write an FsLabel struct to a new file. ### Signature ```rust pub fn write_label + Copy>( path: P, label: &FsLabel, ) -> Result<()> ``` ### Parameters * `path`: A type that implements `AsRef` and `Copy`, representing the file path to write the label to. * `label`: A reference to the `FsLabel` struct to be written. ``` -------------------------------- ### fs_surface::write_surf Source: https://docs.rs/neuroformats/0.3.0/neuroformats/all.html Writes surface data to a file. ```APIDOC ## Function: fs_surface::write_surf ### Description Writes surface data to a file. ### Parameters None explicitly documented. ### Returns Returns a Result indicating success or a NeuroformatsError. ### Example ```rust // Example usage (assuming fs_surface module is imported) // let surface_to_write = ...; // Some FsSurface data // fs_surface::write_surf("path/to/output.surf.gii", &surface_to_write)?; ``` ``` -------------------------------- ### StructuralPartialEq Implementation for FsMghData Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_mgh/struct.FsMghData.html Indicates structural partial equality for FsMghData. -------------------------------- ### Debug Implementation for FsMghData Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_mgh/struct.FsMghData.html Enables debugging output for FsMghData instances. ```APIDOC ### impl Debug for FsMghData #### fn fmt(&self, f: &mut Formatter<'_>) -> Result Formats the value using the given formatter. ``` -------------------------------- ### FsCurvHeader Equality Comparison Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_curv/struct.FsCurvHeader.html Implements PartialEq for FsCurvHeader to allow equality checks between instances. ```rust fn eq(&self, other: &FsCurvHeader) -> bool ``` ```rust fn ne(&self, other: &Rhs) -> bool ``` -------------------------------- ### PartialEq Implementation for FsMghData Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_mgh/struct.FsMghData.html Allows for equality comparison between FsMghData instances. ```APIDOC ### impl PartialEq for FsMghData #### fn eq(&self, other: &FsMghData) -> bool Tests for `self` and `other` values to be equal, and is used by `==`. #### fn ne(&self, other: &Rhs) -> bool Tests for `!=`. ``` -------------------------------- ### move_to Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_surface/struct.BrainMesh.html Moves the mesh to a new location by adding an offset to each vertex, modifying the mesh in place. ```APIDOC ## pub fn move_to(&mut self, offset: (f32, f32, f32)) Move the mesh to a new location by adding the given offset to each vertex. ### Arguments * `offset` - A tuple containing the x, y, and z offsets to apply to each vertex. ### Returns Nothing, changes the mesh in place. ### Examples ```rust // This example uses the center() function to move the mesh to the origin. let mut mesh = neuroformats::BrainMesh::from_obj_file("resources/mesh/cube.obj").unwrap(); let (cx, cy, cz) = mesh.center().unwrap(); mesh.move_to((cx, cy, cz)); ``` ``` -------------------------------- ### FsAnnot::from_file Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_annot/struct.FsAnnot.html Reads an FsAnnot instance from a file path. ```APIDOC ## pub fn from_file + Copy>(path: P) -> Result Read an FsSurface instance from a file. ``` -------------------------------- ### VZip for T Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_mgh/struct.FsMghHeader.html Implementation of the VZip trait for creating a VZip structure. ```APIDOC ## impl VZip for T ### Methods #### fn vzip(self) -> V Creates a VZip structure. ``` -------------------------------- ### fs_surface::read_surf Source: https://docs.rs/neuroformats/0.3.0/neuroformats/all.html Reads a surface file (e.g., .surf.gii, .pial, .white). ```APIDOC ## Function: fs_surface::read_surf ### Description Reads a surface file (e.g., .surf.gii, .pial, .white). ### Parameters None explicitly documented. ### Returns Returns a Result containing the parsed surface data or a NeuroformatsError. ### Example ```rust // Example usage (assuming fs_surface module is imported) // let surface_data = fs_surface::read_surf("path/to/surface.surf.gii")?; ``` ``` -------------------------------- ### Compare FsLabel for Equality Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_label/struct.FsLabel.html Tests if two FsLabel values are equal. ```rust fn eq(&self, other: &FsLabel) -> bool ``` -------------------------------- ### PartialEq Implementation for FsMghData Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_mgh/struct.FsMghData.html Enables comparison of FsMghData instances for equality. ```rust fn eq(&self, other: &FsMghData) -> bool ``` ```rust fn ne(&self, other: &Rhs) -> bool ``` -------------------------------- ### borrow Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_annot/struct.FsAnnot.html Immutably borrows from an owned value. ```APIDOC ## borrow ### Description Immutably borrows from an owned value. ### Signature `fn borrow(&self) -> &T` ``` -------------------------------- ### fs_annot::read_annot Source: https://docs.rs/neuroformats/0.3.0/neuroformats/all.html Reads an FS .annot file, which stores vertex annotations and their associated colors. ```APIDOC ## Function: fs_annot::read_annot ### Description Reads an FS .annot file, which stores vertex annotations and their associated colors. ### Parameters None explicitly documented. ### Returns Returns a Result containing the parsed annotation data or a NeuroformatsError. ### Example ```rust // Example usage (assuming fs_annot module is imported) // let annot_data = fs_annot::read_annot("path/to/annotation.annot")?; ``` ``` -------------------------------- ### VZip Implementation for MultiLane Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_surface/struct.FsSurface.html This snippet shows the implementation of the `VZip` trait for types `T` that implement `MultiLane`. It provides the `vzip` method. ```rust impl VZip for T where V: MultiLane, ``` -------------------------------- ### Clone Implementation for FsMghData Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_mgh/struct.FsMghData.html Provides methods for cloning FsMghData instances. ```rust fn clone(&self) -> FsMghData ``` ```rust fn clone_from(&mut self, source: &Self) ``` -------------------------------- ### Read FsSurface from file Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_surface/fn.read_surf.html Reads a surface mesh from a file path. Use this to load brain hemisphere data. Ensure the path points to a valid surf file. ```rust let surf = neuroformats::read_surf("/path/to/subjects_dir/subject1/surf/lh.white").unwrap(); let num_verts = surf.mesh.vertices.len(); ``` -------------------------------- ### FsMghHeader::from_file Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_mgh/struct.FsMghHeader.html Reads an MGH header from a specified file path. ```APIDOC ## pub fn from_file>(path: P) -> Result ### Description Read an MGH header from a file. ### Method `from_file` ### Parameters #### Path Parameters - **path** (P: AsRef) - Required - The path to the MGH file. ``` -------------------------------- ### to_obj Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_surface/struct.BrainMesh.html Exports the BrainMesh to a Wavefront Object (OBJ) format string. ```APIDOC ## pub fn to_obj(&self) -> String Export a brain mesh to a Wavefront Object (OBJ) format string. ### Examples ```rust let surf = neuroformats::read_surf("/path/to/subjects_dir/subject1/surf/lh.white").unwrap(); let obj_repr = surf.mesh.to_obj(); std::fs::write("/tmp/lhwhite.obj", obj_repr).expect("Unable to write OBJ mesh file"); ``` ``` -------------------------------- ### to_owned Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_annot/struct.FsAnnot.html Creates owned data from borrowed data, usually by cloning. ```APIDOC ## to_owned ### Description Creates owned data from borrowed data, usually by cloning. ### Signature `fn to_owned(&self) -> T` ``` -------------------------------- ### Clone Implementation for FsAnnotColortable Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_annot/struct.FsAnnotColortable.html Provides methods for cloning FsAnnotColortable instances. ```rust fn clone(&self) -> FsAnnotColortable ``` ```rust fn clone_from(&mut self, source: &Self) ``` -------------------------------- ### FsMgh::from_file Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_mgh/struct.FsMgh.html Reads an MGH or MGZ file from the specified path. ```APIDOC ## pub fn from_file + Copy>(path: P) -> Result ### Description Reads an MGH or MGZ file from the specified path. ### Parameters #### Path Parameters - **path** (P) - Required - The path to the MGH or MGZ file. ### Returns - **Result** - Ok(FsMgh) if the file was read successfully, otherwise an Err. ``` -------------------------------- ### FromStr Implementation for FsLabelVertex Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_label/struct.FsLabelVertex.html Enables parsing a string into an FsLabelVertex. The associated error type is NeuroformatsError. ```rust type Err = NeuroformatsError ``` ```rust fn from_str(s: &str) -> Result ``` -------------------------------- ### Default FsCurvHeader Value Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_curv/struct.FsCurvHeader.html Provides a default FsCurvHeader value, useful for initialization. ```rust fn default() -> FsCurvHeader ``` -------------------------------- ### to_string Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_annot/struct.FsAnnot.html Converts the given value to a `String`. ```APIDOC ## to_string ### Description Converts the given value to a `String`. ### Signature `fn to_string(&self) -> String` ``` -------------------------------- ### FsSurfaceHeader::from_file Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_surface/struct.FsSurfaceHeader.html Reads an FsSurface header from a specified file path. ```APIDOC pub fn from_file>(path: P) -> Result Read an FsSurface header from a file. ``` -------------------------------- ### Compare FsCurv for Inequality Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_curv/struct.FsCurv.html Tests if two FsCurv values are not equal. The default implementation is usually sufficient. ```rust fn ne(&self, other: &Rhs) -> bool ``` -------------------------------- ### Read FsSurfaceHeader from File Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_surface/struct.FsSurfaceHeader.html Reads an FsSurface header from a specified file path. Ensure the path is valid and the file exists. ```rust pub fn from_file>(path: P) -> Result ``` -------------------------------- ### read_surf Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_surface/fn.read_surf.html Reads an FsSurface instance from a file. The FsSurface contains a triangular mesh with vertex coordinates and face definitions. Vertex indices are zero-based. ```APIDOC ## Function read_surf ### Signature ```rust pub fn read_surf + Copy>(path: P) -> Result ``` ### Description Reads an FsSurface instance from a file. Surf files store a triangular mesh, where each vertex is defined by its x,y,z coords and each face is defined by 3 vertices, stored as 3 row-indices into the vertices matrix. These vertex indices are zero-based. The mesh typically represents a single brain hemisphere. See `crate::read_curv` to read per-vertex data for the mesh and `crate::read_annot` to read atlas-based parcellations. ### Example ```rust let surf = neuroformats::read_surf("/path/to/subjects_dir/subject1/surf/lh.white").unwrap(); let num_verts = surf.mesh.vertices.len(); ``` ``` -------------------------------- ### Convert f32 values to RGB colors Source: https://docs.rs/neuroformats/0.3.0/neuroformats/util/fn.values_to_colors.html Use this function to convert a slice of f32 values into a vector of RGB colors. Input values outside the min_val and max_val range will be clamped. The output is a Vec where each color is R, G, B. ```rust use neuroformats::util::values_to_colors; let values = vec![0.0, 0.5, 1.1]; let min_val = 0.0; let max_val = 1.0; let colors = values_to_colors(&values, min_val, max_val); assert_eq!(colors, vec![68, 1, 84, 38, 130, 142, 254, 232, 37]); ``` -------------------------------- ### fs_label Module Functions Source: https://docs.rs/neuroformats/0.3.0/neuroformats/index.html Functions for reading FreeSurfer label files. ```APIDOC ## fs_label Module ### `read_label` Reads a FreeSurfer label file. ### `write_label` Writes data to a FreeSurfer label file. ### `FsLabel` Represents a FreeSurfer label file. ``` -------------------------------- ### fs_mgh::write_mgh Source: https://docs.rs/neuroformats/0.3.0/neuroformats/all.html Writes data to an FS .mgh or .mgz file. ```APIDOC ## Function: fs_mgh::write_mgh ### Description Writes data to an FS .mgh or .mgz file. ### Parameters None explicitly documented. ### Returns Returns a Result indicating success or a NeuroformatsError. ### Example ```rust // Example usage (assuming fs_mgh module is imported) // let mgh_data_to_write = ...; // Some MGH data structure // fs_mgh::write_mgh("path/to/output.mgh", &mgh_data_to_write)?; ``` ``` -------------------------------- ### Generic TryFrom Implementation Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_annot/struct.FsAnnotColorRegion.html Attempts to perform a conversion from type `U` into type `T`, returning a `Result`. ```rust type Error = Infallible ``` ```rust fn try_from(value: U) -> Result>::Error> ``` -------------------------------- ### Check Vertex Inclusion in FsLabel Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_label/struct.FsLabel.html Generates a boolean vector indicating for each vertex whether it is part of the label. Requires the total number of surface vertices. Panics if num_surface_verts is smaller than the max index stored in the label. ```rust pub fn is_surface_vertex_in_label(&self, num_surface_verts: usize) -> Vec ``` -------------------------------- ### borrow_mut Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_annot/struct.FsAnnot.html Mutably borrows from an owned value. ```APIDOC ## borrow_mut ### Description Mutably borrows from an owned value. ### Signature `fn borrow_mut(&mut self) -> &mut T` ``` -------------------------------- ### Generic TryInto Implementation Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_annot/struct.FsAnnotColorRegion.html Attempts to perform a conversion from type `T` into type `U`, returning a `Result`. ```rust type Error = >::Error ``` ```rust fn try_into(self) -> Result>::Error> ``` -------------------------------- ### fs_curv Module Functions Source: https://docs.rs/neuroformats/0.3.0/neuroformats/index.html Functions for managing FreeSurfer per-vertex data in binary ‘curv’ files. ```APIDOC ## fs_curv Module ### `read_curv` Reads a FreeSurfer curv file. ### `write_curv` Writes data to a FreeSurfer curv file. ### `FsCurv` Represents a FreeSurfer curv file. ### `FsCurvHeader` Represents the header of a FreeSurfer curv file. ``` -------------------------------- ### TryInto for T Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_mgh/struct.FsMghHeader.html Implementation of the TryInto trait for converting one type into another. ```APIDOC ## impl TryInto for T ### Associated Types #### type Error = >::Error ### Methods #### fn try_into(self) -> Result>::Error> Performs the conversion. ``` -------------------------------- ### Compare FsSurface for Equality Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_surface/struct.FsSurface.html Tests if two FsSurface instances are equal using the PartialEq trait. ```rust fn eq(&self, other: &FsSurface) -> bool ``` -------------------------------- ### Compare FsSurfaceHeader for Equality Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_surface/struct.FsSurfaceHeader.html Tests if two FsSurfaceHeader instances are equal. This comparison checks all fields for equality. ```rust fn eq(&self, other: &FsSurfaceHeader) -> bool ``` -------------------------------- ### Compute Min/Max Coordinates Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_surface/fn.coord_extrema.html Use this function to find the bounding box of a set of 3D coordinates. Ensure the input vector has a length that is a multiple of 3 and contains valid floating-point numbers. ```rust let coords: Vec = vec![0.0, 0.1, 0.2, 0.3, 0.3, 0.3, 1.0, 2.0, 4.0]; let (minx, maxx, miny, maxy, minz, maxz) = neuroformats::fs_surface::coord_extrema(&coords).unwrap(); assert_eq!(0.0, minx); assert_eq!(0.1, miny); assert_eq!(0.2, minz); assert_eq!(1.0, maxx); assert_eq!(2.0, maxy); assert_eq!(4.0, maxz); ``` -------------------------------- ### Clone FsLabel Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_label/struct.FsLabel.html Returns a duplicate of the FsLabel value. ```rust fn clone(&self) -> FsLabel ``` -------------------------------- ### TryFrom for T Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_mgh/struct.FsMghHeader.html Implementation of the TryFrom trait for converting one type into another. ```APIDOC ## impl TryFrom for T ### Associated Types #### type Error = Infallible ### Methods #### fn try_from(value: U) -> Result>::Error> Performs the conversion. ``` -------------------------------- ### into_either Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_annot/struct.FsAnnot.html Converts `self` into a `Left` or `Right` variant of `Either` based on the `into_left` flag. ```APIDOC ## into_either ### Description Converts `self` into a `Left` variant of `Either` if `into_left` is `true`. Converts `self` into a `Right` variant of `Either` otherwise. ### Signature `fn into_either(self, into_left: bool) -> Either` ``` -------------------------------- ### fs_surface functions Source: https://docs.rs/neuroformats Functions for managing FreeSurfer brain surface meshes in binary ‘surf’ files. ```APIDOC ## Re-exports `pub use fs_surface::coord_center;` `pub use fs_surface::coord_extrema;` `pub use fs_surface::read_surf;` `pub use fs_surface::write_surf;` `pub use fs_surface::BrainMesh;` `pub use fs_surface::FsSurface;` `pub use fs_surface::FsSurfaceHeader;` ``` -------------------------------- ### is_gz_file Source: https://docs.rs/neuroformats/0.3.0/neuroformats/util/fn.is_gz_file.html Checks whether the file extension ends with ".gz". This is a simple check and does not guarantee that the file is actually gzipped. ```APIDOC ## Function is_gz_file ### Summary ```rust pub fn is_gz_file

(path: P) -> bool where P: AsRef, ``` ### Description Check whether the file extension ends with ".gz". This is a simple check and does not guarantee that the file is actually gzipped. ### Example ```rust use std::path::Path; use neuroformats::util::is_gz_file; assert_eq!(is_gz_file("example.gz"), true); assert_eq!(is_gz_file("example.txt"), false); ``` ### Arguments * `path` - A path to the file to check. ### Returns * `true` if the file name ends with ".gz", `false` otherwise. ### Note This function does not check the actual content of the file. ``` -------------------------------- ### into_either_with Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_annot/struct.FsAnnot.html Converts `self` into a `Left` or `Right` variant of `Either` based on the result of the provided closure. ```APIDOC ## into_either_with ### Description Converts `self` into a `Left` variant of `Either` if `into_left(&self)` returns `true`. Converts `self` into a `Right` variant of `Either` otherwise. ### Signature `fn into_either_with(self, into_left: F) -> Either` where F: FnOnce(&Self) -> bool ``` -------------------------------- ### write_mgh Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_mgh/fn.write_mgh.html Writes an FsMgh struct to a file. The format (MGH or MGZ) is determined by the file extension: `.mgz` for MGZ, otherwise MGH. ```APIDOC ## write_mgh ### Description Write an FsMgh struct to a file in MGH or MGZ format. Whether MGH or MGZ format should be used is determined from the file extension according to the following rule: files ending with `.mgz` are written in MGZ format, all others are written in MGH format. ### Signature ```rust pub fn write_mgh + Copy>(path: P, mgh: &FsMgh) -> Result<()> ``` ### Parameters * `path`: A type that implements `AsRef` and `Copy`, representing the file path to write to. * `mgh`: A reference to an `FsMgh` struct to be written. ``` -------------------------------- ### From for NeuroformatsError Source: https://docs.rs/neuroformats/0.3.0/neuroformats/error/enum.NeuroformatsError.html This implementation allows converting a standard I/O Error into a NeuroformatsError, simplifying error handling when dealing with file operations. ```APIDOC ## impl From for NeuroformatsError ### fn from(err: IOError) -> NeuroformatsError Converts to this type from the input type. ``` -------------------------------- ### Default FsSurfaceHeader Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_surface/struct.FsSurfaceHeader.html Provides a default FsSurfaceHeader value. This is useful for initializing the struct when no specific data is available. ```rust fn default() -> FsSurfaceHeader ``` -------------------------------- ### From for NeuroformatsError Implementation Source: https://docs.rs/neuroformats/0.3.0/neuroformats/error/enum.NeuroformatsError.html This implementation allows converting a standard I/O Error into a NeuroformatsError. This is useful for propagating I/O errors within the context of neuroformats operations. ```rust impl From for NeuroformatsError { fn from(err: IOError) -> NeuroformatsError { NeuroformatsError::Io(err) } } ``` -------------------------------- ### Write FsMgh to MGH/MGZ Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_mgh/fn.write_mgh.html Use this function to write an FsMgh struct to a file. The format is automatically determined by the file extension (`.mgz` for MGZ, others for MGH). ```rust pub fn write_mgh + Copy>(path: P, mgh: &FsMgh) -> Result<()> ``` -------------------------------- ### fs_label functions Source: https://docs.rs/neuroformats Functions for reading FreeSurfer label files. ```APIDOC ## Re-exports `pub use fs_label::read_label;` `pub use fs_label::write_label;` `pub use fs_label::FsLabel;` ``` -------------------------------- ### Export BrainMesh to PLY Format with Vertex Colors Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_surface/struct.BrainMesh.html Exports a brain mesh to the PLY (Polygon File Format) string, optionally including vertex colors. Ensure vertex colors are provided in RGB format and match the number of vertices. ```rust let surf = neuroformats::read_surf("/path/to/subject/surf/lh.white").unwrap(); let colors = vec![255; surf.mesh.vertices.len()]; // White colors for all vertices let ply_repr = surf.mesh.to_ply(Some(&colors)); std::fs::write("/tmp/lhwhite.ply", ply_repr).expect("Unable to write PLY mesh file"); ``` -------------------------------- ### fs_annot Module Functions Source: https://docs.rs/neuroformats/0.3.0/neuroformats/index.html Functions for managing FreeSurfer brain surface parcellations in annot files. ```APIDOC ## fs_annot Module ### `read_annot` Reads a FreeSurfer annot file. ### `FsAnnot` Represents a FreeSurfer annot file. ### `FsAnnotColortable` Represents the colortable associated with an annot file. ``` -------------------------------- ### values_to_colors Source: https://docs.rs/neuroformats/0.3.0/neuroformats/util/fn.values_to_colors.html Converts a slice of f32 values to a vector of RGB colors using the Viridis colormap. Values are normalized based on min_val and max_val, and clamped if outside this range. The output is a Vec where each color is R, G, B. ```APIDOC ## values_to_colors ### Description Convert a slice of f32 values to a vector of RGB colors using the Viridis colormap. This function takes a slice of f32 values and maps them to RGB colors using the Viridis colormap. The values are normalized to the range [0, 1] based on the provided minimum and maximum values. The resulting colors are returned as a vector of u8 values, where each color is represented by three consecutive u8 values (R, G, B). ### Arguments * `values` - A slice of f32 values to be converted to colors. * `min_val` - The minimum value for normalization. If the values argument contains values less than this, they will be clamped to this value. * `max_val` - The maximum value for normalization. If the values argument contains values greater than this, they will be clamped to this value. ### Returns * A vector of u8 values representing the RGB colors. ### Example ```rust use neuroformats::util::values_to_colors; let values = vec![0.0, 0.5, 1.1]; let min_val = 0.0; let max_val = 1.0; let colors = values_to_colors(&values, min_val, max_val); assert_eq!(colors, vec![68, 1, 84, 38, 130, 142, 254, 232, 37]); ``` ### Note The input values should be in the range [min_val, max_val]. Values outside this range will be clamped. The resulting colors are in the RGB format, where each color is represented by three consecutive u8 values (R, G, B). The colors are generated using the Viridis colormap, which is perceptually uniform and colorblind-friendly. ``` -------------------------------- ### is_mgz_file Source: https://docs.rs/neuroformats/0.3.0/neuroformats/fs_mgh/fn.is_mgz_file.html Checks whether the file extension ends with ".mgz". ```APIDOC ## is_mgz_file ### Description Checks whether the file extension ends with ".mgz". ### Signature ```rust pub fn is_mgz_file

(path: P) -> bool where P: AsRef, ``` ### Parameters * `path`: A type that can be converted to a reference to a `Path`. ### Returns `true` if the file extension is ".mgz", `false` otherwise. ``` -------------------------------- ### Re-exports Source: https://docs.rs/neuroformats/0.3.0/neuroformats/index.html This section lists functions and types that are re-exported from other modules, making them directly accessible from the top-level neuroformats crate. ```APIDOC ## Re-exports `pub use fs_annot::read_annot;` `pub use fs_annot::FsAnnot;` `pub use fs_annot::FsAnnotColortable;` `pub use fs_curv::read_curv;` `pub use fs_curv::write_curv;` `pub use fs_curv::FsCurv;` `pub use fs_curv::FsCurvHeader;` `pub use fs_label::read_label;` `pub use fs_label::write_label;` `pub use fs_label::FsLabel;` `pub use fs_mgh::read_mgh;` `pub use fs_mgh::write_mgh;` `pub use fs_mgh::FsMgh;` `pub use fs_mgh::FsMghData;` `pub use fs_mgh::FsMghHeader;` `pub use fs_mgh::MRI_FLOAT;` `pub use fs_mgh::MRI_INT;` `pub use fs_mgh::MRI_SHORT;` `pub use fs_mgh::MRI_UCHAR;` `pub use fs_surface::coord_center;` `pub use fs_surface::coord_extrema;` `pub use fs_surface::read_surf;` `pub use fs_surface::write_surf;` `pub use fs_surface::BrainMesh;` `pub use fs_surface::FsSurface;` `pub use fs_surface::FsSurfaceHeader;` `pub use util::values_to_colors;` `pub use util::vec32minmax;` ```