102 lines
3.0 KiB
Rust
102 lines
3.0 KiB
Rust
//! Error types for anatomy file reading
|
|
|
|
use std::io;
|
|
use std::path::PathBuf;
|
|
use thiserror::Error;
|
|
|
|
/// Errors that can occur when reading FreeSurfer anatomy files
|
|
#[derive(Debug, Error)]
|
|
pub enum AnatomyError {
|
|
/// I/O error during file operations
|
|
#[error("I/O error: {0}")]
|
|
Io(#[from] io::Error),
|
|
|
|
/// Invalid magic number in file header
|
|
#[error("Invalid magic number in file: expected {expected:?}, found {found:?}")]
|
|
InvalidMagic {
|
|
/// The expected magic bytes for the file format
|
|
expected: Vec<u8>,
|
|
/// The actual magic bytes found in the file
|
|
found: Vec<u8>,
|
|
},
|
|
|
|
/// Surface file not found
|
|
#[error("Surface file not found: {path}")]
|
|
SurfaceNotFound {
|
|
/// Path to the missing surface file
|
|
path: PathBuf,
|
|
},
|
|
|
|
/// Annotation file not found
|
|
#[error("Annotation file not found: {path}")]
|
|
AnnotationNotFound {
|
|
/// Path to the missing annotation file
|
|
path: PathBuf,
|
|
},
|
|
|
|
/// Curvature file not found
|
|
#[error("Curvature file not found: {path}")]
|
|
CurvatureNotFound {
|
|
/// Path to the missing curvature file
|
|
path: PathBuf,
|
|
},
|
|
|
|
/// Invalid FreeSurfer subject directory
|
|
#[error("Invalid FreeSurfer subject directory: {path}")]
|
|
InvalidSubjectDir {
|
|
/// Path to the invalid subject directory
|
|
path: PathBuf,
|
|
},
|
|
|
|
/// Surface not loaded
|
|
#[error("Surface not loaded: {hemisphere:?} {surface_type:?}")]
|
|
SurfaceNotLoaded {
|
|
/// The hemisphere (left or right) of the missing surface
|
|
hemisphere: super::Hemisphere,
|
|
/// The type of surface (e.g., pial, white, inflated) that was not loaded
|
|
surface_type: super::SurfaceType,
|
|
},
|
|
|
|
/// Annotation not loaded
|
|
#[error("Annotation not loaded: {hemisphere:?} {atlas}")]
|
|
AnnotationNotLoaded {
|
|
/// The hemisphere (left or right) of the missing annotation
|
|
hemisphere: super::Hemisphere,
|
|
/// The atlas name (e.g., aparc, aparc.a2009s) that was not loaded
|
|
atlas: String,
|
|
},
|
|
|
|
/// Invalid vertex count
|
|
#[error("Invalid vertex count: expected {expected}, found {found}")]
|
|
InvalidVertexCount {
|
|
/// The expected number of vertices
|
|
expected: usize,
|
|
/// The actual number of vertices found
|
|
found: usize,
|
|
},
|
|
|
|
/// Invalid face count
|
|
#[error("Invalid face count: found {count}")]
|
|
InvalidFaceCount {
|
|
/// The invalid face count found in the file
|
|
count: usize,
|
|
},
|
|
|
|
/// Unsupported file format version
|
|
#[error("Unsupported format version: {version}")]
|
|
UnsupportedVersion {
|
|
/// The unsupported version number encountered
|
|
version: i32,
|
|
},
|
|
|
|
/// Color table parsing error
|
|
#[error("Color table parsing error: {message}")]
|
|
ColorTableError {
|
|
/// Description of the color table parsing error
|
|
message: String,
|
|
},
|
|
}
|
|
|
|
/// Result type for anatomy operations
|
|
pub type Result<T> = std::result::Result<T, AnatomyError>;
|