Skip to content

Commit

Permalink
notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
camisowers committed Aug 15, 2023
1 parent bbbd026 commit 8c34b21
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/toffy/image_stitching.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ def fix_image_resolutions(resolution_data, extraction_dir):
tiff_data = load_utils.load_imgs_from_tree(extraction_dir, fovs=[fov])

# scale and save every channel image
print(f"Changing {fov} from {tiff_data.shape[1]} to {tiff_data.shape[1]*scale}.")
for channel in tiff_data.channels.values:
channel_data = tiff_data.loc[fov, :, :, channel]
rescale = rescale_image(
Expand Down
21 changes: 14 additions & 7 deletions templates/3f_check_resolutions.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"id": "b4edefe7-7f3a-4883-bcb3-47158753c837",
"metadata": {},
"source": [
"### Step 1: Check resolutions"
"**Step 1: Check resolutions**"
]
},
{
Expand All @@ -65,13 +65,20 @@
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "cc4eade1-9fad-458f-92cf-8beebed0209f",
"metadata": {},
"outputs": [],
"cell_type": "markdown",
"id": "4dd4ce41-a637-4358-abdd-2d333a64e4d8",
"metadata": {
"execution": {
"iopub.execute_input": "2023-08-15T18:57:42.867715Z",
"iopub.status.busy": "2023-08-15T18:57:42.866942Z",
"iopub.status.idle": "2023-08-15T18:57:42.879774Z",
"shell.execute_reply": "2023-08-15T18:57:42.878978Z",
"shell.execute_reply.started": "2023-08-15T18:57:42.867666Z"
},
"tags": []
},
"source": [
"### Step 2: Chane resolutions"
"**Step 2: Change image sizes**"
]
},
{
Expand Down
5 changes: 4 additions & 1 deletion tests/image_stitching_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,12 +322,15 @@ def test_fix_image_resolutions(mocked_print):
)
image_stitching.fix_image_resolutions(extra_data, tmpdir)
mocked_print.mock_calls == [call("No resolution scaling needed for any FOVs in this run.")]
mocked_print.reset_mock()

# test image resolution change
resolution_data = pd.DataFrame(
{"fov": fov_list, "pixels / 400 microns": [512, 1024, 512, 256]}
{"fov": fov_list, "pixels / 400 microns": [1024, 2048, 1024, 512]}
)
image_stitching.fix_image_resolutions(resolution_data, tmpdir)
mocked_print.mock_calls[0] == call("Changing fov-2-scan-1 from 10 to 5.")
mocked_print.mock_calls[1] == call("Changing fov-4-scan-1 from 10 to 20.")

# check downscale for fov 2
tiff_data = load_utils.load_imgs_from_tree(tmpdir, fovs=["fov-2-scan-1"])
Expand Down

0 comments on commit 8c34b21

Please sign in to comment.