-
Notifications
You must be signed in to change notification settings - Fork 237
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 #469 from MouseLand/test-separation
Test type separation
- Loading branch information
Showing
12 changed files
with
113 additions
and
101 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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 @@ | ||
|
||
|
||
import numpy as np | ||
from pathlib import Path | ||
from tifffile import imread | ||
from suite2p import io | ||
|
||
from utils import get_binary_file_data | ||
|
||
|
||
def test_tiff_reconstruction_from_binary_file(test_ops): | ||
""" | ||
Tests to see if tif generated by tiff_to_binary and write_tiff matches test tif. | ||
""" | ||
test_ops['tiff_list'] = ['input.tif'] | ||
op = io.tiff_to_binary(test_ops)[0] | ||
output_data = get_binary_file_data(op) | ||
# Make sure data in matrix is nonnegative | ||
assert np.all(output_data >= 0) | ||
fname = io.generate_tiff_filename( | ||
functional_chan=op['functional_chan'], | ||
align_by_chan=op['align_by_chan'], | ||
save_path=op['save_path'], | ||
k=0, | ||
ichan=True | ||
) | ||
io.save_tiff(output_data, fname=fname) | ||
reconstructed_tiff_data = imread( | ||
str(Path(test_ops['save_path0']).joinpath('suite2p', 'plane0', 'reg_tif', 'file000_chan0.tif')) | ||
) | ||
# Compare to our test data | ||
prior_data = imread( | ||
str(Path(test_ops['data_path'][0]).joinpath('1plane1chan', 'suite2p', 'test_write_tiff.tif')) | ||
) | ||
assert np.array_equal(reconstructed_tiff_data, prior_data) | ||
|
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
File renamed without changes.
File renamed without changes.
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,58 @@ | ||
import numpy as np | ||
from suite2p.registration import bidiphase, utils | ||
|
||
|
||
def test_spatial_smooth_has_not_regressed_during_refactor(): | ||
frames = np.ones((2, 3, 3)) | ||
smoothed = utils.spatial_smooth(frames, 2) | ||
expected = np.array([ | ||
[[1. , 1. , 0.5 ], | ||
[1. , 1. , 0.5 ], | ||
[0.5 , 0.5 , 0.25]], | ||
|
||
[[1. , 1. , 0.5 ], | ||
[1. , 1. , 0.5 ], | ||
[0.5 , 0.5 , 0.25]]], dtype=np.float32) | ||
assert np.allclose(smoothed, expected) | ||
|
||
|
||
def test_positive_bidiphase_shift_shifts_every_other_line(): | ||
orig = np.array([ | ||
[[1, 2, 3, 4, 5, 6, 7], | ||
[1, 2, 3, 4, 5, 6, 7], | ||
[1, 2, 3, 4, 5, 6, 7], | ||
[1, 2, 3, 4, 5, 6, 7], | ||
[1, 2, 3, 4, 5, 6, 7]] | ||
]) | ||
expected = np.array([ | ||
[[1, 2, 3, 4, 5, 6, 7], | ||
[1, 2, 1, 2, 3, 4, 5], | ||
[1, 2, 3, 4, 5, 6, 7], | ||
[1, 2, 1, 2, 3, 4, 5], | ||
[1, 2, 3, 4, 5, 6, 7]] | ||
]) | ||
|
||
shifted = orig.copy() | ||
bidiphase.shift(shifted, 2) | ||
assert np.allclose(shifted, expected) | ||
|
||
|
||
def test_negative_bidiphase_shift_shifts_every_other_line(): | ||
orig = np.array([ | ||
[[1, 2, 3, 4, 5, 6, 7], | ||
[1, 2, 3, 4, 5, 6, 7], | ||
[1, 2, 3, 4, 5, 6, 7], | ||
[1, 2, 3, 4, 5, 6, 7], | ||
[1, 2, 3, 4, 5, 6, 7]] | ||
]) | ||
expected = np.array([ | ||
[[1, 2, 3, 4, 5, 6, 7], | ||
[3, 4, 5, 6, 7, 6, 7], | ||
[1, 2, 3, 4, 5, 6, 7], | ||
[3, 4, 5, 6, 7, 6, 7], | ||
[1, 2, 3, 4, 5, 6, 7]] | ||
]) | ||
|
||
shifted = orig.copy() | ||
bidiphase.shift(shifted, -2) | ||
assert np.allclose(shifted, expected) |
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