forked from NeuralEnsemble/python-neo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added test for asciiimageio.py and test_tiffio.py
added installation of pillow via setup (review based) minor modification of asciiimageio and tiff
- Loading branch information
Showing
10 changed files
with
116 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,4 @@ ipython | |
https://github.com/nsdf/nsdf/archive/0.1.tar.gz | ||
coverage | ||
coveralls | ||
pillow |
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
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,43 @@ | ||
""" | ||
Test of neo.io.asciiimageio | ||
""" | ||
import os | ||
import unittest | ||
import quantities as pq | ||
from neo.io import AsciiImageIO | ||
import numpy as np | ||
|
||
|
||
class TestAsciiImageIO(unittest.TestCase): | ||
|
||
def test_read_txt(self): | ||
img = '' | ||
img_list = [] | ||
for frame in range(20): | ||
img_list.append([]) | ||
for y in range(50): | ||
img_list[frame].append([]) | ||
for x in range(50): | ||
img += str(x) | ||
img += '\t' | ||
img_list[frame][y].append(x) | ||
img_list = np.array(img_list) | ||
file_name = "txt_test_file.txt" | ||
file = open(file_name, mode="w") | ||
file.write(str(img)) | ||
file.close() | ||
|
||
object = AsciiImageIO(file_name='txt_test_file.txt', | ||
nb_frame=20, nb_row=50, nb_column=50, units='V', | ||
sampling_rate=1 * pq.Hz, spatial_scale=1 * pq.micrometer) | ||
block = object.read_block() | ||
self.assertEqual(len(block.segments), 1) | ||
self.assertEqual(len(block.segments[0].imagesequences), 1) | ||
self.assertEqual(block.segments[0].imagesequences[0].shape, (20, 50, 50)) | ||
self.assertEqual(block.segments[0].imagesequences[0].any(), img_list.any()) | ||
|
||
file.close() | ||
os.remove(file_name) | ||
|
||
if __name__ == "__main__": | ||
unittest.main() |
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,43 @@ | ||
|
||
import unittest | ||
import os | ||
from PIL import Image | ||
import numpy as np | ||
import shutil | ||
from neo.io.tiffio import TiffIO | ||
import quantities as pq | ||
|
||
class TestTiffIO(unittest.TestCase): | ||
|
||
|
||
def test_read_group_of_tiff_grayscale(self): | ||
directory = 'test_tiff' | ||
if not os.path.exists(directory): | ||
os.makedirs(directory) | ||
# directory is live | ||
img = [] | ||
for picture in range(10): | ||
img.append([]) | ||
for y in range(50): | ||
img[picture].append([]) | ||
for x in range(50): | ||
img[picture][y].append(x) | ||
img = np.array(img, dtype=float) | ||
for image in range(10): | ||
Image.fromarray(img[image]).save(directory+'/tiff_exemple'+str(image)+".tif") | ||
|
||
ioclass = TiffIO(directory_path=directory, units='V', sampling_rate=1.0*pq.Hz, | ||
spatial_scale=1.0*pq.micrometer) | ||
blck = ioclass.read_block() | ||
self.assertEqual(len(blck.segments), 1) | ||
self.assertEqual(len(blck.segments[0].imagesequences), 1) | ||
self.assertEqual(blck.segments[0].imagesequences[0].any(), img.any()) | ||
self.assertEqual(blck.segments[0].imagesequences[0].sampling_rate, 1.0*pq.Hz) | ||
self.assertEqual(blck.segments[0].imagesequences[0].spatial_scale, 1.0 * pq.micrometer) | ||
|
||
# end of directory | ||
shutil.rmtree(directory) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
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