-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ENH: Add reading and writing adapters for deflated TS
- Loading branch information
1 parent
57d8907
commit 4c1cd85
Showing
5 changed files
with
134 additions
and
51 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,38 @@ | ||
|
||
use std::{io::BufReader, fs::File}; | ||
use std::{io::BufReader, fs::{metadata, File}}; | ||
|
||
// use dicom_object::OpenFileOptions; | ||
// use dicom_pixeldata::PixelDecoder; | ||
|
||
// #[test] | ||
// fn test_read_data_with_preamble() { | ||
// let path = dicom_test_files::path("pydicom/image_dfl.dcm").expect("test DICOM file should exist"); | ||
// let source = BufReader::new(File::open(path).unwrap()); | ||
use dicom_object::OpenFileOptions; | ||
use dicom_pixeldata::PixelDecoder; | ||
|
||
// // should read preamble even though it's from a reader | ||
// let object = OpenFileOptions::new() | ||
// .from_reader(source) | ||
// .expect("Should read from source successfully"); | ||
#[test] | ||
fn test_read_data_deflated() { | ||
let path = dicom_test_files::path("pydicom/image_dfl.dcm").expect("test DICOM file should exist"); | ||
let source = BufReader::new(File::open(path).unwrap()); | ||
|
||
// let res = object.decode_pixel_data(); | ||
// println!("{:?}", res); | ||
// should read preamble even though it's from a reader | ||
let object = OpenFileOptions::new() | ||
.from_reader(source) | ||
.expect("Should read from source successfully"); | ||
|
||
// } | ||
let res = object.decode_pixel_data().unwrap(); | ||
assert_eq!(( | ||
res.rows() as usize * | ||
res.columns() as usize * | ||
res.number_of_frames() as usize), res.data().len() as usize); | ||
} | ||
|
||
#[test] | ||
fn write_deflated(){ | ||
let path = dicom_test_files::path("pydicom/image_dfl.dcm").expect("test DICOM file should exist"); | ||
let source = BufReader::new(File::open(path.clone()).unwrap()); | ||
|
||
// should read preamble even though it's from a reader | ||
let object = OpenFileOptions::new() | ||
.from_reader(source) | ||
.expect("Should read from source successfully"); | ||
|
||
let mut buf = Vec::<u8>::new(); | ||
object.write_all(&mut buf).unwrap(); | ||
assert_eq!(buf.len(), metadata(path).unwrap().len() as usize); | ||
} |