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
8178f935
Commit
8178f935
authored
10 months ago
by
pswain
Browse files
Options
Downloads
Patches
Plain Diff
added sorting2
parent
68d4b0ee
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
src/wela/sorting.py
+33
-0
33 additions, 0 deletions
src/wela/sorting.py
with
33 additions
and
0 deletions
src/wela/sorting.py
0 → 100644
+
33
−
0
View file @
8178f935
import
numpy
as
np
def
sort_by_budding
(
buddings
,
bud_number
=
0
):
"""
Return indices for each cell when a particular budding occurs.
"""
bud_indices
=
np
.
transpose
(
np
.
nonzero
(
buddings
))
sort_order
=
[]
for
cell_i
in
range
(
buddings
.
shape
[
0
]):
cell_buds
=
bud_indices
[
bud_indices
[:,
0
]
==
cell_i
,
:]
if
bud_number
<
cell_buds
.
shape
[
0
]:
sort_order
.
append
(
cell_buds
[
bud_number
][
1
])
else
:
sort_order
.
append
(
np
.
nan
)
sort_order
=
np
.
array
(
sort_order
)
return
sort_order
def
sort_by_maximum
(
data
,
byfunction
=
None
):
"""
Return indices of cells sorted by largest value.
"""
sort_order
=
np
.
nan
*
np
.
ones
(
data
.
shape
[
0
])
sdata
=
data
[
not_all_nan
(
data
),
:]
if
byfunction
is
not
None
:
sorted_indices
=
np
.
argsort
(
byfunction
(
sdata
,
axis
=
1
))
else
:
sorted_indices
=
np
.
nanargmax
(
sdata
,
axis
=
1
)
sort_order
[
not_all_nan
(
data
)]
=
sorted_indices
return
sort_order
def
not_all_nan
(
data
):
"""
Find rows that are not all NaN.
"""
indices
=
~
np
.
all
(
np
.
isnan
(
data
),
axis
=
1
)
return
indices
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