Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
alibylite
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
Swain Lab
aliby
alibylite
Commits
3540fb26
Commit
3540fb26
authored
3 years ago
by
Alán Muñoz
Browse files
Options
Downloads
Patches
Plain Diff
add CellsLinear
parent
cf74a396
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
io/cells.py
+48
-1
48 additions, 1 deletion
io/cells.py
with
48 additions
and
1 deletion
io/cells.py
+
48
−
1
View file @
3540fb26
...
@@ -51,7 +51,7 @@ class Cells:
...
@@ -51,7 +51,7 @@ class Cells:
# Convert sparse arrays if needed and if kind is 'mask' it fills the outline
# Convert sparse arrays if needed and if kind is 'mask' it fills the outline
array
=
Cells
.
_asdense
(
array
)
array
=
Cells
.
_asdense
(
array
)
if
kind
==
"
mask
"
:
if
kind
==
"
mask
"
:
array
=
ndimage
.
binary_fill_holes
(
array
).
astype
(
int
)
array
=
ndimage
.
binary_fill_holes
(
array
).
astype
(
bool
)
return
array
return
array
@classmethod
@classmethod
...
@@ -192,6 +192,53 @@ class CellsHDF(Cells):
...
@@ -192,6 +192,53 @@ class CellsHDF(Cells):
return
self
.
group_by_traps
(
traps
,
labels
)
return
self
.
group_by_traps
(
traps
,
labels
)
class
CellsLinear
(
CellsHDF
):
"""
Reimplement functions from CellsHDF to save edgemasks in a (N,tile_size, tile_size) array
"""
def
__init__
(
self
,
filename
,
path
=
"
cell_info
"
):
super
().
__init__
(
filename
,
path
=
path
)
def
__getitem__
(
self
,
item
):
assert
item
!=
"
edgemasks
"
,
"
Edgemasks must not be loaded as a whole
"
_item
=
"
_
"
+
item
if
not
hasattr
(
self
,
_item
):
setattr
(
self
,
_item
,
self
.
_fetch
(
item
))
return
getattr
(
self
,
_item
)
def
_fetch
(
self
,
path
):
with
h5py
.
File
(
self
.
filename
,
mode
=
"
r
"
)
as
f
:
return
f
[
self
.
cinfo_path
][
path
][()]
def
_edgem_from_masking
(
self
,
mask
):
with
h5py
.
File
(
self
.
filename
,
mode
=
"
r
"
)
as
f
:
edgem
=
f
[
self
.
cinfo_path
+
"
/edgemasks
"
][
mask
,
...]
return
edgem
def
_edgem_where
(
self
,
cell_id
,
trap_id
):
id_mask
=
self
.
_get_idx
(
cell_id
,
trap_id
)
edgem
=
self
.
_edgem_from_masking
(
id_mask
)
return
edgem
def
outline
(
self
,
cell_id
,
trap_id
):
id_mask
=
self
.
_get_idx
(
cell_id
,
trap_id
)
times
=
self
[
"
timepoint
"
][
id_mask
]
return
times
,
self
.
edgem_from_masking
(
id_mask
)
def
at_time
(
self
,
timepoint
,
kind
=
"
mask
"
):
ix
=
self
[
"
timepoint
"
]
==
timepoint
traps
=
self
[
"
trap
"
][
ix
]
edgemasks
=
self
.
_edgem_from_masking
(
ix
)
masks
=
[
self
.
_astype
(
edgemask
,
kind
)
for
edgemask
in
edgemasks
if
edgemask
.
any
()
]
return
self
.
group_by_traps
(
traps
,
masks
)
class
CellsMat
(
Cells
):
class
CellsMat
(
Cells
):
def
__init__
(
self
,
mat_object
):
def
__init__
(
self
,
mat_object
):
super
(
CellsMat
,
self
).
__init__
()
super
(
CellsMat
,
self
).
__init__
()
...
...
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