-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new sample data and test for file utils
- Loading branch information
1 parent
1cc595e
commit 71f9b2c
Showing
4 changed files
with
68 additions
and
10 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
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,46 @@ | ||
import unittest | ||
|
||
import numpy as np | ||
from elf.io import open_file | ||
from synaptic_reconstruction.sample_data import get_sample_data | ||
|
||
|
||
class TestFileUtils(unittest.TestCase): | ||
|
||
def test_read_mrc_2d(self): | ||
from synaptic_reconstruction.file_utils import read_mrc | ||
|
||
file_path = get_sample_data("tem_2d") | ||
data, voxel_size = read_mrc(file_path) | ||
|
||
with open_file(file_path, "r") as f: | ||
data_exp = f["data"][:] | ||
|
||
self.assertTrue(data.shape, data_exp.shape) | ||
self.assertTrue(np.allclose(data, data_exp)) | ||
|
||
resolution = 0.592 | ||
self.assertTrue(np.isclose(voxel_size["x"], resolution)) | ||
self.assertTrue(np.isclose(voxel_size["y"], resolution)) | ||
self.assertTrue(np.isclose(voxel_size["z"], 0.0)) | ||
|
||
def test_read_mrc_3d(self): | ||
from synaptic_reconstruction.file_utils import read_mrc | ||
|
||
file_path = get_sample_data("tem_tomo") | ||
data, voxel_size = read_mrc(file_path) | ||
|
||
with open_file(file_path, "r") as f: | ||
data_exp = f["data"][:] | ||
|
||
self.assertTrue(data.shape, data_exp.shape) | ||
self.assertTrue(np.allclose(data, data_exp)) | ||
|
||
resolution = 1.554 | ||
self.assertTrue(np.isclose(voxel_size["x"], resolution)) | ||
self.assertTrue(np.isclose(voxel_size["y"], resolution)) | ||
self.assertTrue(np.isclose(voxel_size["z"], resolution)) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |