Skip to content
Snippets Groups Projects
Commit 18eae790 authored by polarbean's avatar polarbean
Browse files

modify atlas slicing logic

parent f2f94cfb
No related branches found
No related tags found
No related merge requests found
...@@ -360,6 +360,7 @@ def detect_pixel_id(segmentation: np.array): ...@@ -360,6 +360,7 @@ def detect_pixel_id(segmentation: np.array):
def get_region_areas( def get_region_areas(
use_flat,
atlas_labels, atlas_labels,
flat_file_atlas, flat_file_atlas,
seg_width, seg_width,
...@@ -385,10 +386,10 @@ def get_region_areas( ...@@ -385,10 +386,10 @@ def get_region_areas(
Returns: Returns:
DataFrame: DataFrame with region areas. DataFrame: DataFrame with region areas.
""" """
image = load_image(flat_file_atlas,slice_dict["anchoring"], atlas_volume, triangulation, (seg_width, seg_height)) atlas_map = load_image(flat_file_atlas,slice_dict["anchoring"], atlas_volume, triangulation, (seg_width, seg_height), atlas_labels)
region_areas, atlas_map = flat_to_dataframe( region_areas = flat_to_dataframe(
image, atlas_labels, flat_file_atlas, (seg_width, seg_height) atlas_map, (seg_width, seg_height)
) )
return region_areas, atlas_map return region_areas, atlas_map
...@@ -440,6 +441,7 @@ def segmentation_to_atlas_space( ...@@ -440,6 +441,7 @@ def segmentation_to_atlas_space(
else: else:
damage_mask = None damage_mask = None
region_areas, atlas_map = get_region_areas( region_areas, atlas_map = get_region_areas(
use_flat,
atlas_labels, atlas_labels,
flat_file_atlas, flat_file_atlas,
seg_width, seg_width,
......
...@@ -270,10 +270,7 @@ def warp_image(image, triangulation, rescaleXY): ...@@ -270,10 +270,7 @@ def warp_image(image, triangulation, rescaleXY):
def flat_to_dataframe( def flat_to_dataframe(
image, image,
labelfile, rescaleXY=None):
rescaleXY=None,
image_vector=None,
volume=None,):
""" """
Converts a flat file to a DataFrame. Converts a flat file to a DataFrame.
...@@ -290,16 +287,11 @@ def flat_to_dataframe( ...@@ -290,16 +287,11 @@ def flat_to_dataframe(
np.array: array in shape of alignment XY scaled by rescaleXY with allen ID for each point np.array: array in shape of alignment XY scaled by rescaleXY with allen ID for each point
""" """
scale_factor = calculate_scale_factor(image, rescaleXY) scale_factor = calculate_scale_factor(image, rescaleXY)
allen_id_image = ( df_area_per_label = count_pixels_per_label(image, scale_factor)
assign_labels_to_image(image, labelfile) return df_area_per_label
if (image_vector is None or volume is None)
else image
)
df_area_per_label = count_pixels_per_label(allen_id_image, scale_factor)
return df_area_per_label, allen_id_image
def load_image(file, image_vector, volume, triangulation, rescaleXY): def load_image(file, image_vector, volume, triangulation, rescaleXY, labelfile=None):
""" """
Loads an image from a file or generates it from a vector and volume. Loads an image from a file or generates it from a vector and volume.
...@@ -318,10 +310,13 @@ def load_image(file, image_vector, volume, triangulation, rescaleXY): ...@@ -318,10 +310,13 @@ def load_image(file, image_vector, volume, triangulation, rescaleXY):
image = np.float64(image) image = np.float64(image)
if triangulation is not None: if triangulation is not None:
image = warp_image(image, triangulation, rescaleXY) image = warp_image(image, triangulation, rescaleXY)
elif file.endswith(".flat"): else:
image = read_flat_file(file) if file.endswith(".flat"):
elif file.endswith(".seg"): image = read_flat_file(file)
image = read_seg_file(file) if file.endswith(".seg"):
image = read_seg_file(file)
image = assign_labels_to_image(image, labelfile)
return image return image
......
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