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
3411a3b0
Commit
3411a3b0
authored
2 years ago
by
Harry Carey
Browse files
Options
Downloads
Patches
Plain Diff
renamed main file to pynutil and introduced a workflow example
parent
778b42dc
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
PyNutil.py
+1
-17
1 addition, 17 deletions
PyNutil.py
basic_workflow.py
+20
-0
20 additions, 0 deletions
basic_workflow.py
reformat_allen_label.py
+11
-0
11 additions, 0 deletions
reformat_allen_label.py
with
32 additions
and
17 deletions
P
rojectSegmentation3D_vec
.py
→
P
yNutil
.py
+
1
−
17
View file @
3411a3b0
...
@@ -26,7 +26,7 @@ def assignPointsToRegions(points, regionVolume):
...
@@ -26,7 +26,7 @@ def assignPointsToRegions(points, regionVolume):
return
regionDict
return
regionDict
def
transformToRegistration
(
SegHeight
,
SegWidth
,
RegHeight
,
RegWidth
):
def
transformToRegistration
(
SegHeight
,
SegWidth
,
RegHeight
,
RegWidth
):
Yscale
=
RegHeight
/
SegHeight
Yscale
=
RegHeight
/
SegHeight
Xscale
=
RegWidth
/
SegWidth
Xscale
=
RegWidth
/
SegWidth
return
Yscale
,
Xscale
return
Yscale
,
Xscale
...
@@ -97,22 +97,6 @@ def SegmentationToAtlasSpace(slice, SegmentationPath, pixelID='auto', nonLinear=
...
@@ -97,22 +97,6 @@ def SegmentationToAtlasSpace(slice, SegmentationPath, pixelID='auto', nonLinear=
# points = points.reshape(-1)
# points = points.reshape(-1)
return
points
return
points
# def applyTransformationToPoints(ID_pixels, slice,SegHeight, SegWidth, nonLinear=True):
# RegHeight = slice["height"]
# RegWidth = slice["width"]
# #this calculates reg/seg
# Yscale , Xscale = transformToRegistration(SegHeight,SegWidth, RegHeight,RegWidth)
# #this creates a triangulation using the reg width
# triangulation = triangulate(RegWidth, RegHeight, slice["markers"])
# #scale the seg coordinates to reg/seg
# scaledY,scaledX = scalePositions(ID_pixels[0], ID_pixels[1], Yscale, Xscale)
# if nonLinear:
# newX, newY = transform_vec(triangulation, scaledX, scaledY)
# else:
# newX, newY = scaledX, scaledY
# #scale U by Uxyz/RegWidth and V by Vxyz/RegHeight
# points = transformToAtlasSpace(slice['anchoring'], newY, newX, RegHeight, RegWidth)
# return points
def
FolderToAtlasSpace
(
folder
,
QUINT_alignment
,
pixelID
=
[
0
,
0
,
0
],
nonLinear
=
True
):
def
FolderToAtlasSpace
(
folder
,
QUINT_alignment
,
pixelID
=
[
0
,
0
,
0
],
nonLinear
=
True
):
slices
=
loadVisuAlignJson
(
QUINT_alignment
)
slices
=
loadVisuAlignJson
(
QUINT_alignment
)
...
...
This diff is collapsed.
Click to expand it.
basic_workflow.py
0 → 100644
+
20
−
0
View file @
3411a3b0
#pandas is used for working with csv files
import
pandas
as
pd
#nrrd just lets us open nrrd files
import
nrrd
#import our function for converting a folder of segmentations to points
from
PyNutil
import
FolderToAtlasSpace
#now we can use our function to convert the folder of segmentations to points
points
=
FolderToAtlasSpace
(
"
test_data/oneSection15/
"
,
"
test_data/C68_nonlinear.json
"
,
pixelID
=
[
255
,
0
,
255
],
nonLinear
=
True
)
#first we need to find the label file for the volume
label_path
=
"
annotation_volumes//allen2022_colours.csv
"
#then the path to the volume
volume_path
=
"
annotation_volumes//annotation_10.nrrd
"
#read the label file
label_df
=
pd
.
read_csv
(
label_path
)
#read the annotation volume, it also has a header but we don't need it
data
,
header
=
nrrd
.
read
(
volume_path
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
reformat_allen_label.py
0 → 100644
+
11
−
0
View file @
3411a3b0
import
pandas
as
pd
#open colour txt file
path
=
"
itksnap_label_description.txt
"
# use " " as separator
#set column names
df
=
pd
.
read_csv
(
path
,
sep
=
"
"
,
header
=
None
,
names
=
[
"
id
"
,
"
r
"
,
"
g
"
,
"
b
"
,
"
1a
"
,
"
1b
"
,
"
1c
"
,
"
name
"
])
df
[[
"
name
"
,
"
allenID
"
]]
=
df
[
"
name
"
].
str
.
split
(
'
-
'
,
expand
=
True
)
df
.
to_csv
(
"
allen2022_colours.csv
"
,
index
=
False
)
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