Skip to content
Snippets Groups Projects
Commit 31519d85 authored by polarbean's avatar polarbean
Browse files

fix warping bug :tada:

parent fe1bbd45
No related branches found
No related tags found
No related merge requests found
Showing
with 7851 additions and 11 deletions
......@@ -205,11 +205,17 @@ def warp_image(image, triangulation, rescaleXY):
newY = newY.reshape(reg_h, reg_w)
newX = newX.astype(int)
newY = newY.astype(int)
newX[newX >= reg_w] = reg_w - 1
newY[newY >= reg_h] = reg_h - 1
newX[newX < 0] = 0
newY[newY < 0] = 0
new_image = image[newY, newX]
tempX = newX.copy()
tempY = newY.copy()
tempX[tempX >= reg_w] = reg_w - 1
tempY[tempY >= reg_h] = reg_h - 1
tempX[tempX < 0] = 0
tempY[tempY < 0] = 0
new_image = image[tempY, tempX]
new_image[newX >= reg_w] = 0
new_image[newY >= reg_h] = 0
new_image[newX < 0] = 0
new_image[newY < 0] = 0
return new_image
......@@ -225,13 +231,10 @@ def flat_to_dataframe(
image = generate_target_slice(image_vector, volume)
image = np.float64(image)
random_number = np.random.randint(0,1000)
outim = ((image==0) * 255).astype(np.uint8)
cv2.imwrite(f"{random_number}_linear.jpg", outim)
if triangulation is not None:
image = warp_image(image, triangulation, rescaleXY)
outim = ((image==0) * 255).astype(np.uint8)
cv2.imwrite(f"{random_number}_warped.jpg", outim)
elif file.endswith(".flat"):
image = read_flat_file(file)
elif file.endswith(".seg"):
......
import pandas as pd
from .counting_and_load import pixel_count_per_region, label_points
def quantify_labeled_points(
pixel_points,
......@@ -23,9 +22,9 @@ def quantify_labeled_points(
atlas_labels,
)
label_df = _combine_slice_reports(per_section_df, atlas_labels)
return labeled_points, labeled_points_centroids, label_df, per_section_df
def _quantify_per_section(labeled_points, labeled_points_centroids, points_len, centroids_len, region_areas_list, atlas_labels):
prev_pl = 0
......
This diff is collapsed.
tests/expected_outputs/output_nutil_v1_0_5/Images/Test_test_s001.png

15.5 KiB

tests/expected_outputs/output_nutil_v1_0_5/Images/Test_test_s002.png

18.4 KiB

tests/expected_outputs/output_nutil_v1_0_5/Images/Test_test_s003.png

23.8 KiB

tests/expected_outputs/output_nutil_v1_0_5/Images/Test_test_s004.png

23.6 KiB

tests/expected_outputs/output_nutil_v1_0_5/Images/Test_test_s005.png

22.4 KiB

File added
type = Quantifier
name = Test
analysis_type = QUINT
quantifier_input_dir = Z:/HBP_Analytics/PyNutil/PyNutil_testing/Example1_nonlinear_allen_mouse/segmentations
quantifier_atlas_dir = Z:/HBP_Analytics/PyNutil/PyNutil_testing/Example1_nonlinear_allen_mouse/atlasmaps
label_file = Allen Mouse Brain 2017
custom_label_file =
xml_anchor_file = Z:/HBP_Analytics/PyNutil/PyNutil_testing/Example1_nonlinear_allen_mouse/alignment.json
quantifier_output_dir = Z:/HBP_Analytics/PyNutil/PyNutil_testing/Example1_nonlinear_allen_mouse/output_nutil_v1_0_5
output_report = All
extraction_color = 0,0,0,255
object_splitting = Yes
object_min_size = 1
global_pixel_scale = 1
quantifier_pixel_scale_unit = pixels
use_custom_masks = No
custom_mask_directory =
custom_mask_color = 255,255,255,255
output_report_type = CSV
custom_region_type = Default
custom_region_file =
coordinate_extraction = All
coordinate_single_point = No
pixel_density = 1
display_label_id = No
output_region_id = Yes
pattern_match = _sXXX
files =
nutil_version = v1.0.5
nutil_version = v1.0.5
nutil_version = v1.0.5
Region name;Region pixels;Region area;Area unit;Object count;Object pixels;Object area;Area unit;Load;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Cortex;1479642;1479641.710464;pixels;N/A;0;0;pixels;0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Fibretracts;356439;356438.781979;pixels;N/A;100;100;pixels;0.000281;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Hippo;443659;443659.379537;pixels;N/A;600;600;pixels;0.001352;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Olfactory;230189;230188.756416;pixels;N/A;0;0;pixels;0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Hypothalamus;203317;203317.041248;pixels;N/A;0;0;pixels;0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Striatum_Pallidum;849700;849700.402871;pixels;N/A;1500;1500;pixels;0.001765;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Mid_Hind_Medulla;102957;102957.115687;pixels;N/A;0;0;pixels;0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Thalamus;304659;304658.581975;pixels;N/A;800;800;pixels;0.002626;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Cerebellum;0;0;pixels;N/A;0;0;pixels;0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
VentricularSystem;49725;49724.943250;pixels;N/A;0;0;pixels;0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Region name;Region pixels;Region area;Area unit;Object count;Object pixels;Object area;Area unit;Load;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Cortex;308023;308022.687500;pixels;N/A;0;0;pixels;0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Fibretracts;41565;41565.269531;pixels;N/A;0;0;pixels;0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Hippo;3180;3180.024170;pixels;N/A;0;0;pixels;0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Olfactory;38293;38293.214844;pixels;N/A;0;0;pixels;0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Hypothalamus;0;0;pixels;N/A;0;0;pixels;0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Striatum_Pallidum;261151;261150.531250;pixels;N/A;600;600;pixels;0.002298;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Mid_Hind_Medulla;0;0;pixels;N/A;0;0;pixels;0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Thalamus;0;0;pixels;N/A;0;0;pixels;0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Cerebellum;0;0;pixels;N/A;0;0;pixels;0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
VentricularSystem;4571;4570.645508;pixels;N/A;0;0;pixels;0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Region name;Region pixels;Region area;Area unit;Object count;Object pixels;Object area;Area unit;Load;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Cortex;317583;317583.156250;pixels;N/A;0;0;pixels;0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Fibretracts;57240;57240.429688;pixels;N/A;0;0;pixels;0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Hippo;767;766.886841;pixels;N/A;0;0;pixels;0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Olfactory;43610;43610.296875;pixels;N/A;0;0;pixels;0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Hypothalamus;42710;42710.484375;pixels;N/A;0;0;pixels;0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Striatum_Pallidum;360723;360723.156250;pixels;N/A;600;600;pixels;0.001663;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Mid_Hind_Medulla;0;0;pixels;N/A;0;0;pixels;0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Thalamus;0;0;pixels;N/A;0;0;pixels;0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Cerebellum;0;0;pixels;N/A;0;0;pixels;0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
VentricularSystem;11012;11012.495117;pixels;N/A;0;0;pixels;0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Region name;Region pixels;Region area;Area unit;Object count;Object pixels;Object area;Area unit;Load;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Cortex;329097;329096.750000;pixels;N/A;0;0;pixels;0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Fibretracts;84807;84807.460938;pixels;N/A;100;100;pixels;0.001179;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Hippo;31258;31258.310547;pixels;N/A;0;0;pixels;0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Olfactory;52700;52700.464844;pixels;N/A;0;0;pixels;0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Hypothalamus;65789;65788.671875;pixels;N/A;0;0;pixels;0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Striatum_Pallidum;167826;167825.515625;pixels;N/A;300;300;pixels;0.001788;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Mid_Hind_Medulla;0;0;pixels;N/A;0;0;pixels;0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Thalamus;110575;110574.851563;pixels;N/A;200;200;pixels;0.001809;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Cerebellum;0;0;pixels;N/A;0;0;pixels;0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
VentricularSystem;14970;14969.630859;pixels;N/A;0;0;pixels;0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
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