pub struct Nd2File { /* private fields */ }Expand description
Main reader for ND2 files
Implementations§
Source§impl Nd2File
impl Nd2File
Sourcepub fn open_reader<R>(reader: R) -> Result<Self>
pub fn open_reader<R>(reader: R) -> Result<Self>
Sourcepub fn open<P: AsRef<Path>>(path: P) -> Result<Self>
pub fn open<P: AsRef<Path>>(path: P) -> Result<Self>
Open an ND2 file for reading from a local path.
Examples found in repository?
examples/read_summary.rs (line 12)
3fn main() -> Result<()> {
4 let args: Vec<String> = std::env::args().collect();
5
6 if args.len() < 2 {
7 eprintln!("Usage: {} <path-to-nd2-file>", args[0]);
8 std::process::exit(1);
9 }
10
11 let path = &args[1];
12 let mut nd2 = Nd2File::open(path)?;
13
14 println!("=== ND2 File Information ===");
15 println!("Version: {:?}", nd2.version());
16
17 let summary = nd2.summary()?;
18 println!("Logical frames: {}", summary.logical_frame_count);
19 println!("Sizes: {:?}", summary.sizes);
20 println!("Channels: {:?}", summary.channels);
21
22 let first_plane = nd2.read_frame_2d(0, 0, 0, 0)?;
23 println!("First plane pixels: {}", first_plane.len());
24
25 Ok(())
26}Sourcepub fn version(&self) -> (u32, u32)
pub fn version(&self) -> (u32, u32)
Get the file format version (major, minor)
Examples found in repository?
examples/read_summary.rs (line 15)
3fn main() -> Result<()> {
4 let args: Vec<String> = std::env::args().collect();
5
6 if args.len() < 2 {
7 eprintln!("Usage: {} <path-to-nd2-file>", args[0]);
8 std::process::exit(1);
9 }
10
11 let path = &args[1];
12 let mut nd2 = Nd2File::open(path)?;
13
14 println!("=== ND2 File Information ===");
15 println!("Version: {:?}", nd2.version());
16
17 let summary = nd2.summary()?;
18 println!("Logical frames: {}", summary.logical_frame_count);
19 println!("Sizes: {:?}", summary.sizes);
20 println!("Channels: {:?}", summary.channels);
21
22 let first_plane = nd2.read_frame_2d(0, 0, 0, 0)?;
23 println!("First plane pixels: {}", first_plane.len());
24
25 Ok(())
26}Sourcepub fn summary(&mut self) -> Result<DatasetSummary>
pub fn summary(&mut self) -> Result<DatasetSummary>
Return a lightweight dataset overview aligned with other reader crates.
Examples found in repository?
examples/read_summary.rs (line 17)
3fn main() -> Result<()> {
4 let args: Vec<String> = std::env::args().collect();
5
6 if args.len() < 2 {
7 eprintln!("Usage: {} <path-to-nd2-file>", args[0]);
8 std::process::exit(1);
9 }
10
11 let path = &args[1];
12 let mut nd2 = Nd2File::open(path)?;
13
14 println!("=== ND2 File Information ===");
15 println!("Version: {:?}", nd2.version());
16
17 let summary = nd2.summary()?;
18 println!("Logical frames: {}", summary.logical_frame_count);
19 println!("Sizes: {:?}", summary.sizes);
20 println!("Channels: {:?}", summary.channels);
21
22 let first_plane = nd2.read_frame_2d(0, 0, 0, 0)?;
23 println!("First plane pixels: {}", first_plane.len());
24
25 Ok(())
26}Sourcepub fn read_frame(&mut self, index: usize) -> Result<Vec<u16>>
pub fn read_frame(&mut self, index: usize) -> Result<Vec<u16>>
Read one frame by sequence index. Returns pixels as (C, Y, X) u16 data.
Sourcepub fn read_frame_2d(
&mut self,
p: usize,
t: usize,
c: usize,
z: usize,
) -> Result<Vec<u16>>
pub fn read_frame_2d( &mut self, p: usize, t: usize, c: usize, z: usize, ) -> Result<Vec<u16>>
Read 2D Y×X frame at (p,t,c,z). Returns the Y×X pixels for the requested channel.
Examples found in repository?
examples/read_summary.rs (line 22)
3fn main() -> Result<()> {
4 let args: Vec<String> = std::env::args().collect();
5
6 if args.len() < 2 {
7 eprintln!("Usage: {} <path-to-nd2-file>", args[0]);
8 std::process::exit(1);
9 }
10
11 let path = &args[1];
12 let mut nd2 = Nd2File::open(path)?;
13
14 println!("=== ND2 File Information ===");
15 println!("Version: {:?}", nd2.version());
16
17 let summary = nd2.summary()?;
18 println!("Logical frames: {}", summary.logical_frame_count);
19 println!("Sizes: {:?}", summary.sizes);
20 println!("Channels: {:?}", summary.channels);
21
22 let first_plane = nd2.read_frame_2d(0, 0, 0, 0)?;
23 println!("First plane pixels: {}", first_plane.len());
24
25 Ok(())
26}Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Nd2File
impl !Send for Nd2File
impl !Sync for Nd2File
impl !UnwindSafe for Nd2File
impl Freeze for Nd2File
impl Unpin for Nd2File
impl UnsafeUnpin for Nd2File
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more