Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Y
YeaZ-GUI
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
chadhat
YeaZ-GUI
Commits
92e47ea1
Commit
92e47ea1
authored
4 years ago
by
mattminder
Browse files
Options
Downloads
Patches
Plain Diff
Instead of overwriting old file, opens it
parent
9ed705b1
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
disk/InteractionDisk_temp.py
+36
-39
36 additions, 39 deletions
disk/InteractionDisk_temp.py
with
36 additions
and
39 deletions
disk/InteractionDisk_temp.py
+
36
−
39
View file @
92e47ea1
...
@@ -9,7 +9,7 @@ reads the hdf file containing the segmentation.
...
@@ -9,7 +9,7 @@ reads the hdf file containing the segmentation.
from
nd2reader
import
ND2Reader
from
nd2reader
import
ND2Reader
#import matplotlib.pyplot as plt
#import matplotlib.pyplot as plt
import
numpy
as
np
import
numpy
as
np
import
re
import
h5py
import
h5py
import
os.path
import
os.path
import
skimage
import
skimage
...
@@ -24,15 +24,15 @@ import hungarian as hu
...
@@ -24,15 +24,15 @@ import hungarian as hu
# import matplotlib.pyplot as plt
# import matplotlib.pyplot as plt
class
Reader
:
class
Reader
:
def
__init__
(
self
,
hdfpathname
,
newhdfname
,
nd2pathname
):
def
__init__
(
self
,
hdfpathname
,
newhdfname
,
nd2pathname
):
"""
# Initializes the data corresponding to the sizes of the pictures,
Initializes the data corresponding to the sizes of the pictures,
# the number of different fields of views(Npos) taken in the experiment.
the number of different fields of views(Npos) taken in the experiment.
# And it also sets the number of time frames per field of view.
And it also sets the number of time frames per field of view.
"""
# Identify filetype of image file
# Identify filetype of image file
_
,
self
.
extension
=
os
.
path
.
splitext
(
nd2pathname
)
_
,
self
.
extension
=
os
.
path
.
splitext
(
nd2pathname
)
...
@@ -40,9 +40,15 @@ class Reader:
...
@@ -40,9 +40,15 @@ class Reader:
self
.
istiff
=
self
.
extension
==
'
.tif
'
or
self
.
extension
==
'
.tiff
'
self
.
istiff
=
self
.
extension
==
'
.tif
'
or
self
.
extension
==
'
.tiff
'
self
.
isfolder
=
self
.
extension
==
''
self
.
isfolder
=
self
.
extension
==
''
self
.
nd2path
=
nd2pathname
# path name is nd2path for legacy reasons
self
.
nd2path
=
nd2pathname
# path name is nd2path for legacy reasons
self
.
hdfpath
=
hdfpathname
self
.
hdfpath
=
hdfpathname
# Create newhdfname with right path
templist
=
self
.
nd2path
.
split
(
'
/
'
)
tmp
=
""
for
k
in
range
(
0
,
len
(
templist
)
-
1
):
tmp
+=
templist
[
k
]
+
'
/
'
self
.
newhdfpath
=
tmp
+
newhdfname
+
'
.h5
'
self
.
newhdfname
=
newhdfname
self
.
newhdfname
=
newhdfname
if
self
.
isnd2
:
if
self
.
isnd2
:
...
@@ -66,24 +72,20 @@ class Reader:
...
@@ -66,24 +72,20 @@ class Reader:
self
.
channel_names
=
[
'
Channel1
'
]
self
.
channel_names
=
[
'
Channel1
'
]
elif
self
.
isfolder
:
elif
self
.
isfolder
:
filelist
=
sorted
(
os
.
listdir
(
self
.
nd2path
))
filelist
=
sorted
(
os
.
listdir
(
self
.
nd2path
))
print
(
filelist
)
for
f
in
filelist
:
for
f
in
filelist
:
if
f
.
startswith
(
'
.
'
):
if
f
.
startswith
(
'
.
'
):
filelist
.
remove
(
f
)
filelist
.
remove
(
f
)
self
.
sizey
=
0
self
.
sizey
=
0
self
.
sizex
=
0
self
.
sizex
=
0
# filter filelist for supported image files
filelist
=
[
f
for
f
in
filelist
if
re
.
search
(
r
"
.png|.tif|.jpg|.bmp|.jpeg|.pbm|.pgm|.ppm|.pxm|.pnm|.jp2
"
,
f
)]
for
f
in
filelist
:
for
f
in
filelist
:
im
=
skimage
.
io
.
imread
(
self
.
nd2path
+
'
/
'
+
f
)
im
=
skimage
.
io
.
imread
(
self
.
nd2path
+
'
/
'
+
f
)
self
.
sizey
=
max
(
self
.
sizey
,
im
.
shape
[
0
])
#SJR: changed by me
self
.
sizey
=
max
(
self
.
sizey
,
im
.
shape
[
0
])
#SJR: changed by me
self
.
sizex
=
max
(
self
.
sizex
,
im
.
shape
[
1
])
#SJR: changed by me
self
.
sizex
=
max
(
self
.
sizex
,
im
.
shape
[
1
])
#SJR: changed by me
# im = skimage.io.imread(self.nd2path + '/' + filelist[0])
# self.sizey, self.sizex = im.shape #SJR: changed by me
self
.
sizec
=
1
self
.
sizec
=
1
self
.
Npos
=
1
self
.
Npos
=
1
self
.
sizet
=
len
(
filelist
)
self
.
sizet
=
len
(
filelist
)
...
@@ -102,15 +104,8 @@ class Reader:
...
@@ -102,15 +104,8 @@ class Reader:
self
.
predictname
=
''
self
.
predictname
=
''
self
.
thresholdname
=
''
self
.
thresholdname
=
''
self
.
segmentname
=
''
self
.
segmentname
=
''
# self.channelwindow = chch.CustomDialog(self)
# create an new hfd5 file if no one existing already
#
# if self.channelwindow.exec_():
#
# self.default_channel = self.channelwindow.button_channel.currentIndex()
# create an new hfd5 file if no one existing already
self
.
Inithdf
()
self
.
Inithdf
()
...
@@ -134,15 +129,21 @@ class Reader:
...
@@ -134,15 +129,21 @@ class Reader:
a new group is created in the createhdf method
a new group is created in the createhdf method
"""
"""
if
not
self
.
hdfpath
:
newFileExists
=
os
.
path
.
isfile
(
self
.
newhdfpath
)
print
(
newFileExists
)
print
(
self
.
newhdfpath
)
print
(
self
.
hdfpath
)
if
not
self
.
hdfpath
and
not
newFileExists
:
return
self
.
Createhdf
()
return
self
.
Createhdf
()
else
:
else
:
if
not
self
.
hdfpath
:
self
.
hdfpath
=
self
.
newhdfpath
filenamewithpath
,
extension
=
os
.
path
.
splitext
(
self
.
hdfpath
)
filenamewithpath
,
extension
=
os
.
path
.
splitext
(
self
.
hdfpath
)
if
extension
==
"
.h5
"
:
if
extension
==
"
.h5
"
:
temp
=
self
.
hdfpath
[:
-
3
]
temp
=
self
.
hdfpath
[:
-
3
]
self
.
thresholdname
=
temp
+
'
_thresholded
'
+
'
.h5
'
self
.
thresholdname
=
temp
+
'
_thresholded
'
+
'
.h5
'
self
.
segmentname
=
temp
+
'
_segmented
'
+
'
.h5
'
self
.
segmentname
=
temp
+
'
_segmented
'
+
'
.h5
'
self
.
predictname
=
temp
+
'
_predicted
'
+
'
.h5
'
self
.
predictname
=
temp
+
'
_predicted
'
+
'
.h5
'
...
@@ -190,32 +191,27 @@ class Reader:
...
@@ -190,32 +191,27 @@ class Reader:
def
Createhdf
(
self
):
def
Createhdf
(
self
):
"""
In this method, for each field of view one group is created. And
"""
In this method, for each field of view one group is created. And
in each one of these group, there will be for each time frame a
in each one of these group, there will be for each time frame a
corresponding dataset equivalent to a 2d array containing the
corresponding dataset equivalent to a 2d array containing the
corresponding masks data (segmented/thresholded/predicted).
corresponding masks data (segmented/thresholded/predicted).
"""
"""
# print('createhdf')
self
.
hdfpath
=
self
.
newhdfpath
self
.
hdfpath
=
''
templist
=
self
.
nd2path
.
split
(
'
/
'
)
templist
=
self
.
nd2path
.
split
(
'
/
'
)
for
k
in
range
(
0
,
len
(
templist
)
-
1
):
#
for k in range(0, len(templist)-1):
self
.
hdfpath
=
self
.
hdfpath
+
templist
[
k
]
+
'
/
'
#
self.hdfpath = self.hdfpath+templist[k]+'/'
self
.
hdfpath
=
self
.
hdfpath
+
self
.
newhdfname
+
'
.h5
'
#
self.hdfpath = self.hdfpath + self.newhdfname + '.h5'
hf
=
h5py
.
File
(
self
.
hdfpath
,
'
w
'
)
hf
=
h5py
.
File
(
self
.
hdfpath
,
'
w
'
)
for
i
in
range
(
0
,
self
.
Npos
):
for
i
in
range
(
0
,
self
.
Npos
):
grpname
=
self
.
fovlabels
[
i
]
grpname
=
self
.
fovlabels
[
i
]
hf
.
create_group
(
grpname
)
hf
.
create_group
(
grpname
)
hf
.
close
()
hf
.
close
()
for
k
in
range
(
0
,
len
(
templist
)
-
1
):
for
k
in
range
(
0
,
len
(
templist
)
-
1
):
self
.
thresholdname
=
self
.
thresholdname
+
templist
[
k
]
+
'
/
'
self
.
thresholdname
=
self
.
thresholdname
+
templist
[
k
]
+
'
/
'
...
@@ -230,6 +226,7 @@ class Reader:
...
@@ -230,6 +226,7 @@ class Reader:
hf
.
close
()
hf
.
close
()
for
k
in
range
(
0
,
len
(
templist
)
-
1
):
for
k
in
range
(
0
,
len
(
templist
)
-
1
):
self
.
segmentname
=
self
.
segmentname
+
templist
[
k
]
+
'
/
'
self
.
segmentname
=
self
.
segmentname
+
templist
[
k
]
+
'
/
'
self
.
segmentname
=
self
.
segmentname
+
self
.
newhdfname
+
'
_segmented
'
+
'
.h5
'
self
.
segmentname
=
self
.
segmentname
+
self
.
newhdfname
+
'
_segmented
'
+
'
.h5
'
...
@@ -243,6 +240,7 @@ class Reader:
...
@@ -243,6 +240,7 @@ class Reader:
hf
.
close
()
hf
.
close
()
for
k
in
range
(
0
,
len
(
templist
)
-
1
):
for
k
in
range
(
0
,
len
(
templist
)
-
1
):
self
.
predictname
=
self
.
predictname
+
templist
[
k
]
+
'
/
'
self
.
predictname
=
self
.
predictname
+
templist
[
k
]
+
'
/
'
self
.
predictname
=
self
.
predictname
+
self
.
newhdfname
+
'
_predicted
'
+
'
.h5
'
self
.
predictname
=
self
.
predictname
+
self
.
newhdfname
+
'
_predicted
'
+
'
.h5
'
...
@@ -495,7 +493,6 @@ class Reader:
...
@@ -495,7 +493,6 @@ class Reader:
fileprediction
.
close
()
fileprediction
.
close
()
return
np
.
zeros
([
self
.
sizey
,
self
.
sizex
],
dtype
=
np
.
uint16
)
return
np
.
zeros
([
self
.
sizey
,
self
.
sizex
],
dtype
=
np
.
uint16
)
# def LaunchPrediction(self, currentT, currentFOV):
def
TestPredExisting
(
self
,
currentT
,
currentFOV
):
def
TestPredExisting
(
self
,
currentT
,
currentFOV
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment