Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
wela
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
wela
Commits
3e5f041e
Commit
3e5f041e
authored
9 months ago
by
pswain
Browse files
Options
Downloads
Patches
Plain Diff
feature(imageviewer): dded sample_traps_with_cells
parent
e51a5fcd
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
examples/run_imageviewer.py
+2
-1
2 additions, 1 deletion
examples/run_imageviewer.py
src/wela/imageviewer.py
+24
-3
24 additions, 3 deletions
src/wela/imageviewer.py
src/wela/plotting.py
+3
-3
3 additions, 3 deletions
src/wela/plotting.py
with
29 additions
and
7 deletions
examples/run_imageviewer.py
+
2
−
1
View file @
3e5f041e
...
...
@@ -14,12 +14,13 @@ server_info = {
h5file
=
f
"
{
aliby_output
}{
omero_name
}
/
{
position
}
.h5
"
iv
=
ImageViewer
.
remote
(
h5file
,
server_info
,
2104
)
tpt_end
=
10
no_cells
=
4
# for information only
iv
.
print_traps_with_cells
(
tpt_end
)
# use Napari to view cells
# python -m pip install "napari[all]" --upgrade
iv
.
view
(
trap_ids
=
[
4
,
8
,
13
]
,
trap_ids
=
iv
.
sample_traps_with_cells
(
tpt_end
=
tpt_end
,
no_cells
=
no_cells
)
,
tpt_end
=
tpt_end
,
channels_to_skip
=
[
"
cy5
"
],
no_vertical_tiles
=
1
,
...
...
This diff is collapsed.
Click to expand it.
src/wela/imageviewer.py
+
24
−
3
View file @
3e5f041e
from
pathlib
import
Path
import
h5py
import
napari
try
:
import
napari
except
ModuleNotFoundError
:
print
(
"
Napari cannot be imported.
\n
Run
"
,
'
python -m pip install
"
napari[all]
"'
,
)
import
numpy
as
np
from
agora.io.cells
import
Cells
from
aliby.io.image
import
dispatch_image
...
...
@@ -62,7 +69,7 @@ class ImageViewer:
iv
.
cells
=
Cells
.
from_source
(
iv
.
h5file_path
)
return
iv
def
print
_traps_with_cells
(
self
,
tpt_end
,
tpt_start
=
0
):
def
get_all
_traps_with_cells
(
self
,
tpt_end
,
tpt_start
=
0
,
display
=
True
):
"""
List traps with cells.
"""
cells
=
self
.
cells
tpts
=
range
(
tpt_start
,
tpt_end
)
...
...
@@ -72,9 +79,23 @@ class ImageViewer:
if
tpt
in
cells
.
nonempty_tp_in_trap
(
trap_id
):
traps_with_cells
.
append
(
trap_id
)
break
print
(
f
"
Traps with cells
{
traps_with_cells
}
"
)
if
display
:
print
(
f
"
Traps with cells
{
traps_with_cells
}
"
)
return
traps_with_cells
def
sample_traps_with_cells
(
self
,
no_cells
,
tpt_end
,
tpt_start
=
0
):
"""
Sample some traps that have cells.
"""
traps_with_cells
=
self
.
get_all_traps_with_cells
(
tpt_end
,
tpt_start
,
display
=
False
)
rng
=
np
.
random
.
default_rng
()
samples
=
rng
.
integers
(
low
=
0
,
high
=
len
(
traps_with_cells
),
size
=
np
.
min
([
no_cells
,
len
(
traps_with_cells
)]),
)
return
samples
def
get_tiles
(
self
,
trap_id
,
tps
,
channels_to_skip
=
None
,
cell_only
=
True
):
"""
Get dict of tiles with channel indices as keys.
"""
tiles_dict
=
{}
...
...
This diff is collapsed.
Click to expand it.
src/wela/plotting.py
+
3
−
3
View file @
3e5f041e
...
...
@@ -496,7 +496,7 @@ def plot2Dhist(
--------
Load data:
>>>
from
wela.dataloader
import
dataloader
>>>
from
wela.plotting
import
plothist
>>>
from
wela.plotting
import
plot
2D
hist
>>>
dl
=
dataloader
()
>>>
dl
.
load
(
"
1334_2023_03_28_pyrTo2Gal_01glc_00
"
,
use_tsv
=
True
)
>>>
dlc
=
dataloader
()
...
...
@@ -507,8 +507,8 @@ def plot2Dhist(
>>>
tc
,
dc
=
dlc
.
get_time_series
(
"
median_GFP
"
)
Plot both data sets using axes with the same range:
>>>
bins
=
plothist
(
t
,
dc
,
title
=
"
2% Gal
"
,
figsize
=
(
4
,
3
))[
0
]
>>>
plothist
(
t
,
d
,
title
=
"
2% Gal and 0.1% Glu
"
,
bins
=
bins
,
figsize
=
(
4
,
3
))
>>>
bins
=
plot
2D
hist
(
t
,
dc
,
title
=
"
2% Gal
"
,
figsize
=
(
4
,
3
))[
0
]
>>>
plot
2D
hist
(
t
,
d
,
title
=
"
2% Gal and 0.1% Glu
"
,
bins
=
bins
,
figsize
=
(
4
,
3
))
"""
if
x
.
ndim
==
1
:
# make into a 2D array
...
...
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