diff --git a/.vscode/settings.json b/.vscode/settings.json index d35c5419942948e9f9dccac24c74e65b78fc296f..de288e1eab6a537caed290ce0fc5e70be7ae9dba 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,12 +1,3 @@ { - "python.formatting.provider": "black", - "python.testing.unittestArgs": [ - "-v", - "-s", - "./tests", - "-p", - "test*.py" - ], - "python.testing.pytestEnabled": false, - "python.testing.unittestEnabled": true + "python.formatting.provider": "black" } \ No newline at end of file diff --git a/PyNutil/processing/counting_and_load.py b/PyNutil/processing/counting_and_load.py index f7498e2640ab255965e8052b2017e2f463f49197..a22601713b1cb33644658767becccb430e046a48 100644 --- a/PyNutil/processing/counting_and_load.py +++ b/PyNutil/processing/counting_and_load.py @@ -209,10 +209,7 @@ def warp_image(image, triangulation, rescaleXY): newY[newY >= reg_h] = reg_h - 1 newX[newX < 0] = 0 newY[newY < 0] = 0 - new_image = np.zeros_like(image) - mask = (newX <= reg_w) & (newY <= reg_h) & (newX > 0) & (newY > 0) - new_image[mask] = image[mask] - new_image[~mask] = 0 + new_image = image[newY, newX] return new_image @@ -227,8 +224,14 @@ def flat_to_dataframe( if (image_vector is not None) and (volume is not None): 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"): diff --git a/workflows/127_linear.jpg b/workflows/127_linear.jpg new file mode 100644 index 0000000000000000000000000000000000000000..a71a4a447750e4a9c20bbc4ba46082fab4b49263 Binary files /dev/null and b/workflows/127_linear.jpg differ diff --git a/workflows/127_warped.jpg b/workflows/127_warped.jpg new file mode 100644 index 0000000000000000000000000000000000000000..d17c913968813f085986ba905824e5ca417d6584 Binary files /dev/null and b/workflows/127_warped.jpg differ diff --git a/workflows/131_linear.jpg b/workflows/131_linear.jpg new file mode 100644 index 0000000000000000000000000000000000000000..ef7546274d1b8fdeab1e49661cb1ff8dca6f59b4 Binary files /dev/null and b/workflows/131_linear.jpg differ diff --git a/workflows/519_linear.jpg b/workflows/519_linear.jpg new file mode 100644 index 0000000000000000000000000000000000000000..9525247bb716978cbebf104e6b0422fbed9f3dfa Binary files /dev/null and b/workflows/519_linear.jpg differ diff --git a/workflows/519_warped.jpg b/workflows/519_warped.jpg new file mode 100644 index 0000000000000000000000000000000000000000..fa1e72db8526ecbbe500b8062a8f8670a9a6bb3d Binary files /dev/null and b/workflows/519_warped.jpg differ diff --git a/workflows/741_linear.jpg b/workflows/741_linear.jpg new file mode 100644 index 0000000000000000000000000000000000000000..689f856749704bee52219aebb3be78f06eca06df Binary files /dev/null and b/workflows/741_linear.jpg differ diff --git a/workflows/741_warped.jpg b/workflows/741_warped.jpg new file mode 100644 index 0000000000000000000000000000000000000000..d6123c809124dac3e768401e09e8674f441cba1f Binary files /dev/null and b/workflows/741_warped.jpg differ diff --git a/workflows/886_linear.jpg b/workflows/886_linear.jpg new file mode 100644 index 0000000000000000000000000000000000000000..5acba6e9f5825c2a1b54cc1226445b68ea699d5f Binary files /dev/null and b/workflows/886_linear.jpg differ diff --git a/workflows/886_warped.jpg b/workflows/886_warped.jpg new file mode 100644 index 0000000000000000000000000000000000000000..f08b0f532031a120dc7ba5e35d073bc69e15283c Binary files /dev/null and b/workflows/886_warped.jpg differ diff --git a/workflows/basic_example_custom_atlas.py b/workflows/basic_example_custom_atlas.py index 78bdf9705413828b56a2d8a2e77f5ef18f351169..c42727d376028067f8140cbbb8c8e6e199ee4031 100644 --- a/workflows/basic_example_custom_atlas.py +++ b/workflows/basic_example_custom_atlas.py @@ -13,14 +13,15 @@ from PyNutil import PyNutil ###The label_path is the path to the corresponding atlas .csv ###The object_cutoff is a cut-off for min object size ### get_coordinates, if use_flat=True, place flat files in folder titled "flat_files" at same level as "segmentations" folder +#This does not use BrainGlobe API. pnt = PyNutil( - segmentation_folder="../tests/test_data/linear_allen_mouse/", - alignment_json="../tests/test_data/linear_allen_mouse/alignment_linear.json", + segmentation_folder="../tests/test_data/nonlinear_allen_mouse/", + alignment_json="../tests/test_data/nonlinear_allen_mouse/alignment.json", colour=[0, 0, 0], atlas_path="../tests/test_data/allen_mouse_2017_atlas/annotation_25_reoriented_2017.nrrd", label_path="../tests/test_data/allen_mouse_2017_atlas//allen2017_colours.csv", ) pnt.get_coordinates(object_cutoff=0, use_flat=False) pnt.quantify_coordinates() -pnt.save_analysis("../test_result/test_linear_allen_mouse") +pnt.save_analysis("../test_result/test_nonlinear_allen_mouse_noflat_24_02_25")