Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PyNutil
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Harry Carey
PyNutil
Commits
4936347d
Commit
4936347d
authored
1 year ago
by
Sharon Yates
Browse files
Options
Downloads
Patches
Plain Diff
def flat_to_dataframe
parent
eabcdc17
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
PyNutil/coordinate_extraction.py
+1
-1
1 addition, 1 deletion
PyNutil/coordinate_extraction.py
PyNutil/counting_and_load.py
+3
-3
3 additions, 3 deletions
PyNutil/counting_and_load.py
PyNutil/load_workflow.py
+6
-6
6 additions, 6 deletions
PyNutil/load_workflow.py
with
10 additions
and
10 deletions
PyNutil/coordinate_extraction.py
+
1
−
1
View file @
4936347d
...
...
@@ -93,7 +93,7 @@ def folder_to_atlas_space(
object_cutoff
=
0
,
):
"""
Apply Segmentation to atlas space to all segmentations in a folder.
"""
"""
Return pixel_points, centroids, points_len, centroids_len, segmentation_filenames,
"""
# This should be loaded above and passed as an argument
slices
=
load_visualign_json
(
quint_alignment
)
...
...
This diff is collapsed.
Click to expand it.
PyNutil/counting_and_load.py
+
3
−
3
View file @
4936347d
...
...
@@ -117,7 +117,7 @@ def pixel_count_per_region(
"""
Read flat file and write into an np array
"""
"""
Read flat file, write into an np array, assign label file values, return array
"""
def
flat_to_
array
(
flat_file
,
labelfile
):
def
flat_to_
dataframe
(
flat_file
,
labelfile
):
with
open
(
flat_file
,
"
rb
"
)
as
f
:
# I don't know what b is, w and h are the width and height that we get from the
# flat file header
...
...
@@ -145,9 +145,9 @@ def flat_to_array(flat_file, labelfile):
values
=
image_arr
[
coordsx
,
coordsy
]
# assign x,y coords from image_array into values
lbidx
=
labelfile
[
"
idx
"
].
values
allen_id_image
=
lbidx
[
values
.
astype
(
int
)]
return
allen_id_image
#
return allen_id_image
#def count_per_uniqueidx()
#def count_per_uniqueidx()
"""
count pixels for unique idx
"""
unique_ids
,
counts
=
np
.
unique
(
allen_id_image
,
return_counts
=
True
)
...
...
This diff is collapsed.
Click to expand it.
PyNutil/load_workflow.py
+
6
−
6
View file @
4936347d
...
...
@@ -6,27 +6,27 @@ import pandas as pd
import
numpy
as
np
#from read_and_write import flat_to_array, label_to_array
from
counting_and_load
import
flat_to_
array
from
counting_and_load
import
flat_to_
dataframe
base
=
r
"
../test_data/tTA_2877_NOP_s037_atlasmap/2877_NOP_tTA_lacZ_Xgal_s037_nl.flat
"
label
=
r
"
../annotation_volumes\allen2017_colours.csv
"
#image_arr = flat_to_array(base, label)
plt
.
imshow
(
flat_to_array
(
base
,
label
))
#plt.imshow(flat_to_array(base, label))
df_area_per_label
=
flat_to_dataframe
(
base
,
label
)
"""
count pixels in np array for unique idx, return pd df
"""
unique_ids
,
counts
=
np
.
unique
(
allen_id_image
,
return_counts
=
True
)
#
unique_ids, counts = np.unique(allen_id_image, return_counts=True)
area_per_label
=
list
(
zip
(
unique_ids
,
counts
))
#
area_per_label = list(zip(unique_ids, counts))
# create a list of unique regions and pixel counts per region
df_area_per_label
=
pd
.
DataFrame
(
area_per_label
,
columns
=
[
"
idx
"
,
"
area_count
"
])
#
df_area_per_label = pd.DataFrame(area_per_label, columns=["idx", "area_count"])
# create a pandas df with regions and pixel counts
"""
add region name and colours corresponding to each idx into dataframe.
This could be a separate function
"""
...
...
This diff is collapsed.
Click to expand it.
Preview
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!
Save comment
Cancel
Please
register
or
sign in
to comment