-
Notifications
You must be signed in to change notification settings - Fork 115
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 #76 from juglab/issue-73
Fix for bug # 73
- Loading branch information
Showing
6 changed files
with
65 additions
and
19 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 |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = '0.1.10' | ||
__version__ = '0.1.11' |
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,47 @@ | ||
from n2v.internals.N2V_DataGenerator import N2V_DataGenerator | ||
import urllib.request | ||
import os | ||
import zipfile | ||
|
||
|
||
def test_generate_patches_2D(): | ||
|
||
if not os.path.isdir('data'): | ||
os.mkdir('data') | ||
zip_path = "data/RGB.zip" | ||
if not os.path.exists(zip_path): | ||
data = urllib.request.urlretrieve('https://cloud.mpi-cbg.de/index.php/s/Frru2hsjjAljpfW/download', zip_path) | ||
with zipfile.ZipFile(zip_path, 'r') as zip_ref: | ||
zip_ref.extractall('data') | ||
|
||
datagen = N2V_DataGenerator() | ||
|
||
imgs = datagen.load_imgs_from_directory(directory="data", filter='*.png', dims='YXC') | ||
imgs[0] = imgs[0][..., :3] | ||
patches = datagen.generate_patches_from_list(imgs, shape=(1100, 2800)) | ||
assert len(patches) == 1 | ||
patches = datagen.generate_patches_from_list(imgs, shape=(550, 1400)) | ||
assert len(patches) == 4 | ||
patches = datagen.generate_patches_from_list(imgs, shape=(110, 280)) | ||
assert len(patches) == 100 | ||
|
||
def test_generate_patches_3D(): | ||
|
||
if not os.path.isdir('data'): | ||
os.mkdir('data') | ||
zip_path = 'data/flywing-data.zip' | ||
if not os.path.exists(zip_path): | ||
# download and unzip data | ||
data = urllib.request.urlretrieve('https://cloud.mpi-cbg.de/index.php/s/RKStdwKo4FlFrxE/download', zip_path) | ||
with zipfile.ZipFile(zip_path, 'r') as zip_ref: | ||
zip_ref.extractall('data') | ||
|
||
datagen = N2V_DataGenerator() | ||
|
||
imgs = datagen.load_imgs_from_directory(directory="data", filter='*.tif', dims='ZYX') | ||
print(imgs[0].shape) | ||
patches = datagen.generate_patches_from_list(imgs[:1], shape=(35, 520, 692)) | ||
assert len(patches) == 1 | ||
patches = datagen.generate_patches_from_list(imgs[:1], shape=(5, 52, 174)) | ||
assert len(patches) == 210 | ||
|
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