Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ixstools
xrstools
Commits
fc6a4807
Commit
fc6a4807
authored
Nov 10, 2020
by
myron
Browse files
Merge branch 'christoph6' into alessandro_develop
parents
318b17af
5a39cd57
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
XRStools/roifinder_and_gui.py
View file @
fc6a4807
This diff is collapsed.
Click to expand it.
XRStools/xrs_calctools.py
View file @
fc6a4807
...
...
@@ -567,6 +567,24 @@ class xyzAtom:
norm
=
np
.
trapz
(
self
.
spectrum
[
inds
,
1
],
self
.
spectrum
[
inds
,
0
])
self
.
spectrum
[:,
1
]
/=
norm
def
getDist
(
self
,
atom
):
return
np
.
linalg
.
norm
(
self
.
coordinates
-
atom
.
coordinates
)
def
getDistPBCarb
(
self
,
atom
,
lattice
,
lattice_inv
):
return
getDistancePBC_arb
(
self
,
atom
,
lattice
,
lattice_inv
)
def
getAnglePBCarb
(
self
,
atom2
,
atom3
,
lattice
,
lattice_inv
,
degrees
=
True
):
""" **get_angle**
Return angle between the three given atoms (as seen from atom2).
"""
vec1
=
getDistVectorPBC_arb
(
atom2
,
self
,
lattice
,
lattice_inv
)
vec2
=
getDistVectorPBC_arb
(
atom3
,
self
,
lattice
,
lattice_inv
)
dotp
=
np
.
dot
(
vec1
/
np
.
linalg
.
norm
(
vec1
),
vec2
/
np
.
linalg
.
norm
(
vec2
))
if
degrees
:
return
np
.
degrees
(
np
.
arccos
(
np
.
clip
(
dotp
,
-
1.0
,
1.0
)
)
)
else
:
return
np
.
arccos
(
np
.
clip
(
dotp
,
-
1.0
,
1.0
)
)
class
xyzMolecule
:
""" **xyzMolecule**
...
...
XRStools/xrs_read.py
View file @
fc6a4807
...
...
@@ -434,7 +434,7 @@ class Hydra:
print
(
"Integrating pixelwise "
+
scan
)
self
.
scans
[
scan
].
apply_rois_pw
(
self
.
roi_obj
)
def
SumDirect
(
self
,
scan_numbers
):
def
SumDirect
(
self
,
scan_numbers
,
index
=
None
):
""" **SumDirect**
Creates a summed 2D image of a given scan or list of scans.
...
...
@@ -463,9 +463,18 @@ class Hydra:
en_column
=
en_column
,
moni_column
=
self
.
moni_column
)
if
im_sum
is
None
:
im_sum
=
np
.
zeros
(
scan
.
edfmats
[
0
].
shape
,
"f"
)
im_sum
[:]
+=
scan
.
edfmats
.
sum
(
axis
=
0
)
return
im_sum
im_sum1
=
np
.
zeros
(
scan
.
edfmats
[
0
].
shape
,
"f"
)
im_sum2
=
np
.
zeros
(
scan
.
edfmats
[
0
].
shape
,
"f"
)
if
not
index
:
im_sum1
[:]
+=
scan
.
edfmats
.
sum
(
axis
=
0
)
else
:
im_sum1
[:]
+=
scan
.
edfmats
[
0
:
index
,:,:].
sum
(
axis
=
0
)
im_sum2
[:]
+=
scan
.
edfmats
[
index
:,:,:].
sum
(
axis
=
0
)
if
not
index
:
return
im_sum1
else
:
return
im_sum2
-
im_sum1
def
get_eloss_new
(
self
,
method
=
'sum'
):
""" **get_eloss_new**
...
...
@@ -528,8 +537,8 @@ class Hydra:
# master eloss scale in eV is the one of central pixel in first ROI
self
.
signals
=
np
.
zeros
((
len
(
self
.
energy
),
len
(
self
.
cenom_dict
)))
self
.
errors
=
np
.
zeros
((
len
(
self
.
energy
),
len
(
self
.
cenom_dict
)))
master_eloss
=
(
self
.
energy
-
np
.
median
([
np
.
median
(
self
.
cenom_dict
[
key
])
for
key
in
self
.
cenom_dict
])
)
*
1.0e3
self
.
E0
=
np
.
mean
(
self
.
cenom_dict
[
first_key
][
self
.
cenom_dict
[
first_key
]
>
0.0
])
master_eloss
=
(
self
.
energy
-
np
.
median
(
self
.
cenom_dict
[
first_key
][
self
.
cenom_dict
[
first_key
]
>
0.0
])
)
*
1.0e3
self
.
E0
=
np
.
me
di
an
(
self
.
cenom_dict
[
first_key
][
self
.
cenom_dict
[
first_key
]
>
0.0
])
for
key
,
ii
in
zip
(
sorted
(
self
.
cenom_dict
),
range
(
len
(
self
.
cenom_dict
))):
print
(
'Pixel-by-pixel compensation for '
+
key
+
'.'
)
signal
=
np
.
zeros
(
len
(
master_eloss
))
...
...
@@ -539,17 +548,18 @@ class Hydra:
x
=
(
self
.
energy
-
self
.
cenom_dict
[
key
][
dim1
,
dim2
]
)
*
1.0e3
# signals
y
=
self
.
raw_signals
[
key
][:,
dim1
,
dim2
]
#print "Y AMAX", signal.max()
#rbfi = Rbf( x, y, function='linear' )
rbfi
=
interp1d
(
x
,
y
,
bounds_error
=
False
,
fill_value
=
0.0
)
#print "rbf AMAX", Rbf( x, y, function='linear' )
#signal += rbfi( master_eloss )
signal
+=
rbfi
(
master_eloss
)
#print "SIGNAL AMAX", signal.max()
# errors
y
=
self
.
raw_errors
[
key
][:,
dim1
,
dim2
]
rbfi
=
Rbf
(
x
,
y
,
function
=
'linear'
)
error
+=
rbfi
(
master_eloss
)
**
2
if
np
.
any
(
y
)
>
0.0
:
#print "Y AMAX", signal.max()
#rbfi = Rbf( x, y, function='linear' )
rbfi
=
interp1d
(
x
,
y
,
bounds_error
=
False
,
fill_value
=
0.0
)
#print "rbf AMAX", Rbf( x, y, function='linear' )
#signal += rbfi( master_eloss )
signal
+=
rbfi
(
master_eloss
)
#print "SIGNAL AMAX", signal.max()
# errors
y
=
self
.
raw_errors
[
key
][:,
dim1
,
dim2
]
rbfi
=
Rbf
(
x
,
y
,
function
=
'linear'
)
error
+=
rbfi
(
master_eloss
)
**
2
self
.
signals
[:,
ii
]
=
signal
self
.
errors
[:,
ii
]
=
np
.
sqrt
(
error
)
self
.
eloss
=
master_eloss
...
...
XRStools/xrs_rois.py
View file @
fc6a4807
...
...
@@ -44,6 +44,7 @@ import copy
import
h5py
import
os
import
matplotlib.pyplot
as
plt
from
collections
import
Iterable
# commented the *import because otherwise sphinx documents all the symbol of other packages
# from xrs_utilities import *
...
...
@@ -168,32 +169,82 @@ class roi_object:
"""
Container class to hold all relevant information about given ROIs.
"""
def
__init__
(
self
):
self
.
roi_matrix
=
np
.
array
([])
# single matrix of zeros, ones, twos, ... , n's (where n is the number of ROIs defined)
self
.
red_rois
=
{}
# dictionary, one entry for each ROI, each ROI has an origin and a rectangular box of ones and zeros defining the ROI
self
.
indices
=
[]
# list of list of tuples (one list of tuples for each ROI)
self
.
number_of_rois
=
0
# number of ROIs defined
self
.
kind
=
[]
# keyword (e.g. 'zoom', 'line', 'auto', etc.), certain features (esp. in imaging) are only available for certain kinds of ROIs
def
__init__
(
self
):
self
.
roi_matrix
=
np
.
array
([])
# single matrix of zeros, ones, twos, ... ,
# n's (where n is the number of ROIs defined)
self
.
red_rois
=
{}
# dictionary, one entry for each ROI, each ROI
# has an origin and a rectangular box of ones
# and zeros defining the ROI
self
.
indices
=
[]
# list of list of tuples (one list of tuples
# for each ROI)
self
.
number_of_rois
=
0
# number of ROIs defined
self
.
kind
=
[]
# keyword (e.g. 'zoom', 'line', 'auto', etc.),
# certain features (esp. in imaging) are only
# available for certain kinds of ROIs
self
.
x_indices
=
[]
# list of numpy arrays of x-indices (for each ROI)
self
.
y_indices
=
[]
# list of numpy arrays of y-indices (for each ROI)
self
.
masks
=
[]
# 3D numpy array with slices of zeros and ones (same size as detector image) for each roi
self
.
masks
=
[]
# 3D numpy array with slices of zeros and ones (same
# size as detector image) for each roi
self
.
input_image
=
[]
# 2D imput image that was used to define the ROIs
def
__add__
(
self
,
roi_obj
):
""" **__add__**
Allows appending two ROI objects by using the + operator.
"""
assert
(
type
(
roi_obj
)
==
type
(
self
)
)
# create a new instance
new_obj
=
roi_object
()
# copy the ROIs
new_obj
.
red_rois
=
copy
.
deepcopy
(
self
.
red_rois
)
# append the other ROIs
self_len
=
len
(
new_obj
.
red_rois
)
for
ii
,
key
in
enumerate
(
sorted
(
roi_obj
.
red_rois
)
):
new_key
=
'ROI%02d'
%
(
ii
+
self_len
)
if
not
new_key
in
list
(
new_obj
.
red_rois
.
keys
()
):
new_obj
.
red_rois
[
new_key
]
=
roi_obj
.
red_rois
[
key
]
new_obj
.
red_rois
[
new_key
][
1
][
new_obj
.
red_rois
[
new_key
][
1
]
>
0
]
+=
self_len
else
:
'something fishy happened, skipping %s.'
%
(
key
)
return
self
# add the input images
new_obj
.
input_image
=
self
.
input_image
+
roi_obj
.
input_image
# convert summed ROIs to other ROI formats
new_obj
.
roi_matrix
=
convert_redmatrix_to_matrix
(
new_obj
.
red_rois
,
np
.
zeros_like
(
new_obj
.
input_image
),
offsetX
=
0
,
offsetY
=
0
)
new_obj
.
masks
=
convert_roi_matrix_to_masks
(
new_obj
.
roi_matrix
)
new_obj
.
indices
=
convert_matrix_rois_to_inds
(
new_obj
.
roi_matrix
)
new_obj
.
number_of_rois
=
int
(
np
.
amax
(
new_obj
.
roi_matrix
)
)
new_obj
.
x_indices
=
convert_inds_to_xinds
(
new_obj
.
indices
)
new_obj
.
y_indices
=
convert_inds_to_yinds
(
new_obj
.
indices
)
def
load_rois_fromMasksDict
(
self
,
masksDict
,
newshape
=
None
,
kind
=
"zoom"
):
return
new_obj
def
load_rois_fromMasksDict
(
self
,
masksDict
,
newshape
=
None
,
kind
=
"zoom"
):
""" **load_rois_fromMasksDict**
"""
self
.
kind
=
kind
self
.
red_rois
=
masksDict
if
newshape
is
not
None
:
self
.
roi_matrix
=
np
.
zeros
(
newshape
)
self
.
roi_matrix
=
convert_redmatrix_to_matrix
(
masksDict
,
self
.
roi_matrix
,
offsetX
=
0
,
offsetY
=
0
)
self
.
roi_matrix
=
convert_redmatrix_to_matrix
(
masksDict
,
self
.
roi_matrix
,
offsetX
=
0
,
offsetY
=
0
)
self
.
masks
=
convert_roi_matrix_to_masks
(
self
.
roi_matrix
)
self
.
indices
=
convert_matrix_rois_to_inds
(
self
.
roi_matrix
)
self
.
number_of_rois
=
int
(
np
.
amax
(
self
.
roi_matrix
))
self
.
x_indices
=
convert_inds_to_xinds
(
self
.
indices
)
self
.
y_indices
=
convert_inds_to_yinds
(
self
.
indices
)
def
writeH5
(
self
,
fname
):
def
writeH5
(
self
,
fname
):
""" **writeH5**
Creates an HDF5 file and writes the ROIs into it.
Args:
...
...
@@ -215,6 +266,7 @@ class roi_object:
def
loadH5
(
self
,
fname
):
""" **loadH5**
Loads ROIs from an HDF5 file written by the self.writeH5() method.
Args:
...
...
@@ -237,42 +289,65 @@ class roi_object:
self
.
load_rois_fromMasksDict
(
self
.
red_rois
,
newshape
=
shape
,
kind
=
"zoom"
)
else
:
self
.
roi_matrix
=
convert_redmatrix_to_matrix
(
self
.
red_rois
,
np
.
zeros_like
(
self
.
input_image
),
offsetX
=
0
,
offsetY
=
0
)
self
.
roi_matrix
=
convert_redmatrix_to_matrix
(
self
.
red_rois
,
np
.
zeros_like
(
self
.
input_image
),
offsetX
=
0
,
offsetY
=
0
)
self
.
indices
=
convert_matrix_rois_to_inds
(
self
.
roi_matrix
)
self
.
number_of_rois
=
int
(
np
.
amax
(
self
.
roi_matrix
))
self
.
x_indices
=
convert_inds_to_xinds
(
self
.
indices
)
self
.
y_indices
=
convert_inds_to_yinds
(
self
.
indices
)
self
.
masks
=
convert_roi_matrix_to_masks
(
self
.
roi_matrix
)
def
load_shadok_h5
(
self
,
fname
,
group_name1
,
group_name2
=
'ROI_AS_SELECTED'
):
def
load_shadok_h5
(
self
,
fname
,
group_name1
,
group_name2
=
'ROI_AS_SELECTED'
):
""" **load_shadok_h5**
Load ROIs from a HDF5-file created by the Shadok/XRS_Swissknife.
"""
f
=
h5py
.
File
(
fname
,
"r"
)
self
.
input_image
=
f
[
group_name1
][
group_name2
][
"rois_definition"
][
"image"
][:]
self
.
red_rois
=
{}
load_rois_fromh5
(
f
[
group_name1
][
group_name2
],
self
.
red_rois
)
self
.
roi_matrix
=
convert_redmatrix_to_matrix
(
self
.
red_rois
,
np
.
zeros_like
(
self
.
input_image
),
offsetX
=
0
,
offsetY
=
0
)
self
.
roi_matrix
=
convert_redmatrix_to_matrix
(
self
.
red_rois
,
np
.
zeros_like
(
self
.
input_image
),
offsetX
=
0
,
offsetY
=
0
)
self
.
indices
=
convert_matrix_rois_to_inds
(
self
.
roi_matrix
)
self
.
number_of_rois
=
int
(
np
.
amax
(
self
.
roi_matrix
))
self
.
x_indices
=
convert_inds_to_xinds
(
self
.
indices
)
self
.
y_indices
=
convert_inds_to_yinds
(
self
.
indices
)
self
.
masks
=
convert_roi_matrix_to_masks
(
self
.
roi_matrix
)
def
append
(
self
,
roi_object
):
orig_length
=
len
(
self
.
red_rois
)
self
.
indices
.
extend
(
roi_object
.
indices
)
# list of list of tuples (one list of tuples for each ROI)
self
.
number_of_rois
=+
roi_object
.
number_of_rois
# number of ROIs defined
self
.
x_indices
.
extend
(
roi_object
.
x_indices
)
# list of numpy arrays of x-indices (for each ROI)
self
.
y_indices
.
extend
(
roi_object
.
y_indices
)
# list of numpy arrays of y-indices (for each ROI)
#self.masks = [] # 3D numpy array with slices of zeros and ones (same size as detector image) for each roi
#self.input_image += [] # 2D imput image that was used to define the ROIs
roi_object
.
roi_matrix
[
roi_object
.
roi_matrix
>
0
]
+=
orig_length
self
.
roi_matrix
+=
roi_object
.
roi_matrix
# single matrix of zeros, ones, twos, ... , n's (where n is the number of ROIs defined)
def
append
(
self
,
roi_object
):
""" **append**
Append other ROI definitions.
Args:
* roi_object (roi_obj) : Instance of the roi_object class.
"""
assert
(
type
(
roi_object
)
==
type
(
self
)
)
orig_length
=
len
(
self
.
red_rois
)
for
ii
,
key
in
enumerate
(
sorted
(
roi_object
.
red_rois
)):
new_key
=
'ROI%02d'
%
(
ii
+
orig_length
)
self
.
red_rois
[
new_key
]
=
roi_object
.
red_rois
[
key
]
self
.
red_rois
[
new_key
][
1
][
self
.
red_rois
[
new_key
][
1
]
>
0
]
+=
orig_length
def
get_number_of_rois
(
self
):
# convert summed ROIs to other ROI formats
self
.
roi_matrix
=
convert_redmatrix_to_matrix
(
self
.
red_rois
,
np
.
zeros_like
(
self
.
input_image
),
offsetX
=
0
,
offsetY
=
0
)
self
.
masks
=
convert_roi_matrix_to_masks
(
self
.
roi_matrix
)
self
.
indices
=
convert_matrix_rois_to_inds
(
self
.
roi_matrix
)
self
.
number_of_rois
=
int
(
np
.
amax
(
self
.
roi_matrix
)
)
self
.
x_indices
=
convert_inds_to_xinds
(
self
.
indices
)
self
.
y_indices
=
convert_inds_to_yinds
(
self
.
indices
)
def
get_number_of_rois
(
self
):
""" **get_number_of_rois**
Returns the number of currently defined ROIs.
"""
return
self
.
number_of_rois
def
get_indices
(
self
):
...
...
@@ -297,63 +372,113 @@ class roi_object:
"""
return
copy
.
deepcopy
(
self
)
def
strip
_rois
(
self
):
""" **strip
_rois
**
Strips extra zeros
out of
ROIs.
def
strip
(
self
):
""" **strip**
Strips extra zeros
from border of the
ROIs.
"""
pass
for
key
in
self
.
red_rois
:
num
=
int
(
""
.
join
([
c
for
c
in
key
if
c
.
isdigit
()]))
origin
=
self
.
red_rois
[
key
][
0
]
data
=
self
.
red_rois
[
key
][
1
]
inds1
,
inds2
=
np
.
where
(
data
>
0
)
new_data
=
np
.
zeros
((
inds1
.
max
()
-
inds1
.
min
()
+
1
,
inds2
.
max
()
-
inds2
.
min
()
+
1
))
new_data
=
data
[
inds1
,
inds2
].
reshape
(
new_data
)
new_origin
=
(
origin
[
0
]
+
inds1
.
min
(),
origin
[
1
]
+
inds2
.
min
())
self
.
red_rois
[
key
][
0
]
=
new_origin
self
.
red_rois
[
key
][
1
]
=
new_data
def
delete_empty_rois
(
self
):
def
delete_empty_rois
(
self
):
""" **delete_empty_rois**
Deletes ROI entries that are completely empty.
"""
pass
for
key
in
self
.
red_rois
:
if
not
np
.
any
(
self
.
red_rois
[
key
][
1
])
>
0
:
self
.
pop
(
key
)
def
shift
_rois
(
self
,
shiftVal
,
direction
=
'horiz'
,
whichroi
=
None
):
"""
**shift_rois**
def
shift
(
self
,
shiftVal
,
direction
=
'horiz'
,
roi_inds
=
None
):
"""
**shift**
Displaces the defined ROIs by the provided value.
Args
* shiftVal : int
Value by which the ROIs should be shifted.
* direction : string
Description of which direction to shit by.
* whichroi : sequence
Sequence (iterable) for which ROIs should be shifted.
* shiftVal (int) : Value by which the ROIs should be shifted.
* direction (str) : Description of which direction to shift
by (can be 'horiz' or 'vert'), default
is 'horiz'.
* roi_inds (int) or (sequence) : Index or Sequence (iterable)
for which ROIs should be shifted.
If None, all ROIs defined are
shifted (default.)
"""
the_indices
=
[]
if
not
whichroi
:
inds
=
list
(
range
(
len
(
self
.
indice
s
)))
if
not
roi_inds
:
inds
=
list
(
range
(
len
(
self
.
red_roi
s
)))
else
:
inds
=
whichroi
if
direction
==
'vert'
:
for
roi
in
self
.
indices
:
oneroi
=
[]
for
pixel
in
roi
:
oneroi
.
append
(
(
pixel
[
0
]
+
shiftVal
,
pixel
[
1
])
)
the_indices
.
append
(
oneroi
)
if
direction
==
'horiz'
:
for
roi
in
self
.
indices
:
oneroi
=
[]
for
pixel
in
roi
:
oneroi
.
append
(
(
pixel
[
0
],
pixel
[
1
]
+
shiftVal
)
)
the_indices
.
append
(
oneroi
)
self
.
indices
=
the_indices
self
.
roi_matrix
=
convert_inds_to_matrix
(
self
.
indices
,
self
.
input_image
.
shape
)
self
.
red_rois
=
convert_matrix_to_redmatrix
(
self
.
roi_matrix
)
self
.
x_indices
=
convert_inds_to_xinds
(
self
.
indices
)
self
.
y_indices
=
convert_inds_to_yinds
(
self
.
indices
)
self
.
masks
=
convert_roi_matrix_to_masks
(
self
.
roi_matrix
)
inds
=
roi_inds
if
not
isinstance
(
inds
,
Iterable
):
inds
=
list
([
inds
])
for
ind
in
inds
:
key
=
'ROI%02d'
%
ind
if
direction
==
'horiz'
:
self
.
red_rois
[
key
][
0
][
1
]
+=
shiftVal
elif
direction
==
'vert'
:
self
.
red_rois
[
key
][
0
][
0
]
+=
shiftVal
# convert summed ROIs to other ROI formats
self
.
roi_matrix
=
convert_redmatrix_to_matrix
(
self
.
red_rois
,
np
.
zeros_like
(
self
.
input_image
),
offsetX
=
0
,
offsetY
=
0
)
self
.
masks
=
convert_roi_matrix_to_masks
(
self
.
roi_matrix
)
self
.
indices
=
convert_matrix_rois_to_inds
(
self
.
roi_matrix
)
self
.
number_of_rois
=
int
(
np
.
amax
(
self
.
roi_matrix
)
)
self
.
x_indices
=
convert_inds_to_xinds
(
self
.
indices
)
self
.
y_indices
=
convert_inds_to_yinds
(
self
.
indices
)
def
pop
(
self
,
roi_key
=
None
):
""" **pop**
Discards a ROI.
def
show_rois
(
self
,
cmap
=
'Blues'
,
interpolation
=
'nearest'
,
logscaling
=
True
):
""" **show_rois**
Args
* roi_key (str) : Dict key for ROI to delete. If None, the ROI with
highest index (defined last) will be discarded (defalt).
"""
# delete last ROI if no key is specified
if
not
roi_key
:
roi_key
=
sorted
(
list
(
self
.
red_rois
.
keys
()))[
-
1
]
# make sure the ROI exists
assert
(
roi_key
in
list
(
self
.
red_rois
.
keys
())
)
# delete the ROI from the maskDict
self
.
red_rois
.
pop
(
roi_key
)
# convert summed ROIs to other ROI formats
self
.
roi_matrix
=
convert_redmatrix_to_matrix
(
self
.
red_rois
,
np
.
zeros_like
(
self
.
input_image
),
offsetX
=
0
,
offsetY
=
0
)
self
.
masks
=
convert_roi_matrix_to_masks
(
self
.
roi_matrix
)
self
.
indices
=
convert_matrix_rois_to_inds
(
self
.
roi_matrix
)
self
.
number_of_rois
=
int
(
np
.
amax
(
self
.
roi_matrix
)
)
self
.
x_indices
=
convert_inds_to_xinds
(
self
.
indices
)
self
.
y_indices
=
convert_inds_to_yinds
(
self
.
indices
)
def
show
(
self
,
cmap
=
'Blues'
,
interpolation
=
'nearest'
,
logscaling
=
True
):
""" **show**
Creates a figure showing the existing ROIs.
Args:
...
...
@@ -411,9 +536,9 @@ class roi_object:
plt
.
text
(
xcenter
,
ycenter
,
string
)
plt
.
show
()
def
convert_redmatrix_to_matrix
(
masksDict
,
mask
,
offsetX
=
0
,
offsetY
=
0
):
def
convert_redmatrix_to_matrix
(
masksDict
,
mask
,
offsetX
=
0
,
offsetY
=
0
):
for
key
,
(
pos
,
M
)
in
six
.
iteritems
(
masksDict
):
num
=
int
(
""
.
join
([
c
for
c
in
key
if
c
.
isdigit
()]))
S
=
M
.
shape
...
...
@@ -627,7 +752,7 @@ def load_rois_fromh5_address(address):
return
myroi
def
load_rois_fromh5
(
h5group_tot
,
md
,
retrieveImage
=
False
,
metadata
=
None
):
def
load_rois_fromh5
(
h5group_tot
,
md
,
retrieveImage
=
False
,
metadata
=
None
):
h5group
=
h5group_tot
[
"rois_definition/rois_dict"
]
for
key
in
h5group
.
keys
():
md
[
key
]
=
[]
...
...
@@ -649,7 +774,7 @@ def load_rois_fromh5(h5group_tot,md, retrieveImage=False, metadata = None):
else
:
return
shape
def
write_rois_toh5
(
h5group
,
md
,
filterMask
=
None
,
metadata
=
None
):
def
write_rois_toh5
(
h5group
,
md
,
filterMask
=
None
,
metadata
=
None
):
for
key
in
md
.
keys
():
if
key
in
h5group
:
del
h5group
[
key
]
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment