-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #101 from qbio/feature/nifti-extension-writer
Feature/nifti extension writer (task 5 of issue #19)
- Loading branch information
Showing
7 changed files
with
177 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
//! An application for writing a NIFTI file from scratch | ||
extern crate nifti; | ||
|
||
use std::env; | ||
|
||
#[cfg(feature = "ndarray_volumes")] | ||
use crate::nifti::{writer::WriterOptions, Extender, Extension, ExtensionSequence}; | ||
|
||
#[cfg(feature = "ndarray_volumes")] | ||
fn main() { | ||
let mut args = env::args().skip(1); | ||
let filename = args.next().expect("Path to NIFTI file is required"); | ||
|
||
// generate some test data 256x256 float32 | ||
let data = ndarray::Array3::<f32>::zeros((256, 256, 1)); | ||
|
||
let extension1 = Extension::new(8 + 4, 3, vec![0, 0, 0, 0]); | ||
|
||
let extension2 = Extension::from_str(6, "Hello World!"); | ||
|
||
let extension_sequence = ExtensionSequence::new( | ||
Extender::from([1u8, 0u8, 0u8, 0u8]), | ||
vec![extension1, extension2], | ||
); | ||
|
||
WriterOptions::new(&filename) | ||
.with_extensions(extension_sequence) | ||
.write_nifti(&data) | ||
.unwrap(); | ||
} | ||
|
||
#[cfg(not(feature = "ndarray_volumes"))] | ||
fn main() { | ||
println!("This example requires the ndarray_volumes feature to be enabled"); | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters