Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def prop_true_strain_tensor(regionprops_prop, scale):
principal_lengths = np.array(regionprops_prop.principal_lengths)
principal_vectors = regionprops_prop.principal_vectors

denominator = np.power(np.product(principal_lengths), 1 / 3)
denominator = np.power(np.prod(principal_lengths), 1 / 3)
true_strains = np.log(principal_lengths / denominator)

tensor = (
Expand Down
30 changes: 11 additions & 19 deletions src/tapenade/notebooks/deformation_analysis_notebook.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
},
{
"cell_type": "code",
"execution_count": 20,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -103,17 +103,9 @@
},
{
"cell_type": "code",
"execution_count": 55,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"100%|██████████| 5139/5139 [00:06<00:00, 841.33it/s] \n"
]
}
],
"outputs": [],
"source": [
"# props is made of objects 'prop' with many morphological properties\n",
"# like volume, centroid, etc...\n",
Expand Down Expand Up @@ -159,7 +151,7 @@
},
{
"cell_type": "code",
"execution_count": 56,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -191,7 +183,7 @@
},
{
"cell_type": "code",
"execution_count": 57,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -230,7 +222,7 @@
},
{
"cell_type": "code",
"execution_count": 58,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -265,7 +257,7 @@
},
{
"cell_type": "code",
"execution_count": 59,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -298,7 +290,7 @@
},
{
"cell_type": "code",
"execution_count": 60,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -322,7 +314,7 @@
},
{
"cell_type": "code",
"execution_count": 61,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -362,7 +354,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "napari-mine",
"display_name": "test-tapenade",
"language": "python",
"name": "python3"
},
Expand All @@ -376,7 +368,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.16"
"version": "3.10.18"
}
},
"nbformat": 4,
Expand Down
8 changes: 5 additions & 3 deletions src/tapenade/notebooks/preprocessing_notebook.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Before starting, specify if you wish to display each intermediate result in a Napari viewer:"
"Before starting, specify if you wish to display each intermediate result in a Napari viewer\n",
"\n",
"(IF YES,KEEP THE NAPARI WINDOW OPEN)"
]
},
{
Expand Down Expand Up @@ -439,7 +441,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "napari-mine",
"display_name": "test-tapenade",
"language": "python",
"name": "python3"
},
Expand All @@ -453,7 +455,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.16"
"version": "3.10.18"
}
},
"nbformat": 4,
Expand Down
37 changes: 30 additions & 7 deletions src/tapenade/notebooks/registration_notebook.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
"metadata": {},
"source": [
"### <font color='red'> Install the registration package by following the user manual available on Tapenade's GitHub page\n",
"conda install vt -c morpheme\n",
"\n",
"pip install 3D-registration\n",
"</font>"
]
},
Expand Down Expand Up @@ -170,7 +173,7 @@
"filename_ref = list_ref[i]\n",
"filename_float = list_float[i]\n",
"input_voxel = [0.3,0.3,2] #voxel size of your input image (XYZ)\n",
"output_voxel = [0.3,0.3,2] #voxel size of the output registered image (XYZ)\n",
"output_voxel = [1,1,1] #voxel size of the output registered image (XYZ)\n",
"channel_reference = 'hoechst' #name of the ubiquitous channel\n",
"##if you have a first idea of your tranformations (rotation, translation), you can input them here:\n",
"rot = [180,0,0] #XYZ in degrees. ([180,0,0] is a rotation of 180 degrees around the X axis, that we use when flipping the sample)\n",
Expand All @@ -195,7 +198,7 @@
" rot=rot,\n",
" trans2=trans2,\n",
" # input_init_trsf_from_plugin=... #path of the json file saved from the plugin\n",
" save_json=Path(path_to_data) / filename_ref, #to save all parameters\n",
" save_json=Path(path_to_data) / filename_ref, #to save all parameters;\n",
")\n",
"\n",
"##applying the same transformation to the other channels\n",
Expand All @@ -209,7 +212,7 @@
" floating_image=f\"{filename_float}_{channel}.tif\",\n",
" input_voxel=input_voxel,\n",
" output_voxel=output_voxel,\n",
" compute_trsf=0,\n",
" compute_trsf=0\n",
" )"
]
},
Expand Down Expand Up @@ -295,12 +298,32 @@
"metadata": {},
"outputs": [],
"source": [
"reconstruction.write_hyperstacks(\n",
"registered_image = reconstruction.write_hyperstacks(\n",
" path=Path(path_to_data) / filename_ref / \"fused\",\n",
" sample_id=\"fusion\",\n",
" channels=channels\n",
")\n",
"#the result is saved under the name 'sample_id'_registered.tif in the folder 'fused'."
"#the result is saved under the name 'fusion_registered.tif in the folder 'fused'."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "eaf7c4ab-9a65-477e-8cc5-c3075542eb96",
"metadata": {},
"outputs": [],
"source": [
"try:\n",
" import napari\n",
" napari_installed = True\n",
"except ImportError:\n",
" print(\"napari is not installed, skipping visualization step.\")\n",
" napari_installed = False\n",
"\n",
"if napari_installed:\n",
" viewer=napari.Viewer()\n",
" viewer.add_image(registered_image)\n",
" napari.run()"
]
},
{
Expand Down Expand Up @@ -374,7 +397,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "napari-mine",
"display_name": "test-tapenade",
"language": "python",
"name": "python3"
},
Expand All @@ -388,7 +411,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.16"
"version": "3.10.18"
}
},
"nbformat": 4,
Expand Down
89 changes: 18 additions & 71 deletions src/tapenade/notebooks/spatial_correlation_analysis_notebook.ipynb

Large diffs are not rendered by default.

41 changes: 22 additions & 19 deletions src/tapenade/notebooks/spectral_filtering_notebook.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"<h1 style=\"font-size: 48px;\">🏗️</h1> \n",
"<big>This notebook is still under construction !</big>\n",
"<h1 style=\"font-size: 48px;\">⚠️</h1>\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"## Spectral filtering of multichannels images\n",
"\n",
"### <font color='red'> After clicking on a code cell, press \"Shift+Enter\" to run the code, or click on the \"Run\" button in the toolbar above.<br>\n",
"\n",
"### Replace \"...\" signs with the appropriate path to your data.\n",
Expand Down Expand Up @@ -68,7 +62,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -113,24 +107,33 @@
"source": [
"z_to_plot = 50 # index of the z-slice to plot\n",
"\n",
"fout, axarrout = plt.subplots(1,channels, figsize=(20, 5)) \n",
"fig1, ax1 = plt.subplots(1,channels, figsize=(20, 5)) \n",
"\n",
"for i in range(channels):\n",
" axarrout[i].imshow(img[z_to_plot,i,:,:])\n",
" ax1[i].imshow(img[z_to_plot,i,:,:])\n",
"\n",
"fout2, axarrout2 = plt.subplots(1,channels, figsize=(20, 5))\n",
"fig1.suptitle('Channels before spectral filtering')\n",
"fig2, ax2 = plt.subplots(1,channels, figsize=(20, 5))\n",
"\n",
"for i in range(channels):\n",
" axarrout2[i].imshow(image_filtered[z_to_plot,i,:,:])\n",
" ax2[i].imshow(image_filtered[z_to_plot,i,:,:])\n",
"\n",
"fout.tight_layout()\n",
"fout2.tight_layout()"
"fig2.suptitle('Chanels after spectral filtering')\n",
"fig1.tight_layout()\n",
"fig2.tight_layout()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "napari-mine",
"display_name": "test-tapenade",
"language": "python",
"name": "python3"
},
Expand All @@ -144,9 +147,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.16"
"version": "3.10.18"
}
},
"nbformat": 4,
"nbformat_minor": 2
"nbformat_minor": 4
}
6 changes: 2 additions & 4 deletions src/tapenade/reconstruction/_reconstruct.py
Original file line number Diff line number Diff line change
Expand Up @@ -806,10 +806,8 @@ def write_hyperstacks(
tifffile.imwrite(
Path(path) / f"{sample_id}_registered.tif",
new_image.astype(dtype),
imagej=True,
compression=("zlib", 1),
) # float16 not compatible with Fiji

)
return new_image.astype(dtype)

def add_centermass(landmarks, radius: int = 10, centermass_label: int = 10):
"""
Expand Down
Loading