Skip to content
Snippets Groups Projects
Commit 3411a3b0 authored by Harry Carey's avatar Harry Carey
Browse files

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
...@@ -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)
......
#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
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)
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment