From 79556e5b6a5c80f7e76c00d0d882a428681e393d Mon Sep 17 00:00:00 2001 From: Kyle Harrington Date: Wed, 24 May 2023 09:45:58 -0400 Subject: [PATCH 01/11] Add snippet for programmatically setting endpoints @ctrueden provided this information in https://github.com/imagej/napari-imagej/issues/238 --- doc/Configuration.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/Configuration.rst b/doc/Configuration.rst index 263eb9d0..4b6ddb9f 100644 --- a/doc/Configuration.rst +++ b/doc/Configuration.rst @@ -52,6 +52,12 @@ Here are some example endpoint constructions: - ``net.imagej:imagej+net.preibisch:BigStitcher`` - NO +Note that the endpoint can be set programmatically by running the following code before starting napari-imagej: + +.. code-block:: python + + from napari_imagej import settings + settings.imagej_directory_or_endpoint = "sc.fiji:fiji:2.13.0+org.morphonets:SNT:MANAGED" *ImageJ base directory* ^^^^^^^^^^^^^^^^^^^^^^^ From 1e103faa891c26dc1d59e4e3efb72e7601e0102e Mon Sep 17 00:00:00 2001 From: Kyle Harrington Date: Fri, 2 Jun 2023 10:54:43 -0400 Subject: [PATCH 02/11] Add first part of BoneJ2 use case --- doc/Use_Cases.rst | 2 ++ doc/examples/bonej.rst | 78 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 doc/examples/bonej.rst diff --git a/doc/Use_Cases.rst b/doc/Use_Cases.rst index 466f23c3..fc382aaf 100644 --- a/doc/Use_Cases.rst +++ b/doc/Use_Cases.rst @@ -10,6 +10,8 @@ Below we document use cases for the napari-imagej plugin. examples/trackmate_reader.rst + examples/bonej.rst + examples/scripting.rst examples/ops.rst diff --git a/doc/examples/bonej.rst b/doc/examples/bonej.rst new file mode 100644 index 00000000..cd522f8b --- /dev/null +++ b/doc/examples/bonej.rst @@ -0,0 +1,78 @@ +Using BoneJ2 +======================================== + +https://figshare.com/ndownloader/files/13369043 + +The `TrackMate`_ plugin for ImageJ2 provides a streamlined interface for object tracking. +This use case demonstrates how you can use napari-imagej to run the TrackMate plugin on 3D data **(X, Y, Time)** view the results with napari and +also process them with the `napari-stracking`_ plugin. + +Here we adapt a workflow from the BoneJ2 paper (https://wellcomeopenresearch.org/articles/6-37) for use with napari-imagej. + +For this use case we will analyze live cell wide-field microscopy data of HeLa cell nuclei (Hoechst stain), imaged every 30 minutes for 40 frames. +The data used in this use case is available in the `napari-imagej repository`_ on GitHub. + +.. image:: https://media.imagej.net/napari-imagej/trackmate_0.gif + :align: center + +| + +napari Setup +---------------------- + +We will install one additional plugin to support this use case: https://github.com/haesleinhuepf/napari-segment-blobs-and-things-with-membranes + +BoneJ2 Setup +---------------------- + +We need to first specify the endpoint that we will use to access BoneJ2. + +We can configure napari-imagej to use a Fiji installation by opening the settings dialog and changing the ``imagej distribution_or_endpoint`` (described `here <../Configuration.html#imagej-directory-or-endpoint>`_). This example was created using an endpoint of ``sc.fiji:fiji:2.13.0+org.bonej:bonej-ops:MANAGED+org.bonej:bonej-plugins:MANAGED+org.bonej:bonej-utilities:MANAGED``. + +**Note that napari must be restarted for these changes to take effect!** + +Preparing and Opening the Data +------------------ + +We will use the same data that was used in the BoneJ2 paper. Go ahead and download umzc_378p_Apteryx_haastii_head.tif.bz2 from doi:10.6084/m9.figshare.7257179 + +.. |ImageJ2| image:: ../../src/napari_imagej/resources/imagej2-16x16-flat.png + +Opening Data in napari +^^^^^^^^^^^^^^^^^^^^^^ + +If you haven't already unzipped the file, then unzip the file. Once that is complete you can drag-and-drop the image onto napari to open it. + +Processing Data in napari with nsbatwm +^^^^^^^^^^^^^^^^^^^^^^ + +Now we need to process the image. + +1. First, we will blur the image to smooth intensity values and filter noise. + +Within napari's menus choose: `Tools` > `Filtering / noise removal` > `Gaussian (scikit image, nsbatwm)` + +When the widget comes up, change the `sigma` value to 2 and ensure that the image layer is correctly set to the image that was opened. + +2. Now we will threshold the image to make it binary. + +Within napari's menus choose: `Tools` > `Segmentation / binarization` > `Threshold (Li et al 1993, scikit image, nsbatwm)` + +When the widget comes up, ensure that the layer that is selected is the result of step 1. + +3. The result of thresholding is a Label layer, but we will convert it to an Image layer to work with BoneJ2. + +Right click on the layer that was created by step 2 and select `Convert to Image`. + +Processing Data in napari with BoneJ2 and napari-imagej +^^^^^^^^^^^^^^^^^^^^^^ + +Now let's calculate the degree of anisotropy. + +1. In the napari-imagej search bar type `Anisotropy` + +2. Click `Run` + +Select the `inputImage` that corresponds to the theshold layer created previously. + +Check the `Recommended minimums` box From 95056af2aa819d970f4767717ece66abc5d8afc3 Mon Sep 17 00:00:00 2001 From: Kyle Harrington Date: Fri, 2 Jun 2023 10:56:50 -0400 Subject: [PATCH 03/11] Remove old text, clarify direct download link --- doc/examples/bonej.rst | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/doc/examples/bonej.rst b/doc/examples/bonej.rst index cd522f8b..d1779bb5 100644 --- a/doc/examples/bonej.rst +++ b/doc/examples/bonej.rst @@ -1,22 +1,8 @@ Using BoneJ2 ======================================== -https://figshare.com/ndownloader/files/13369043 - -The `TrackMate`_ plugin for ImageJ2 provides a streamlined interface for object tracking. -This use case demonstrates how you can use napari-imagej to run the TrackMate plugin on 3D data **(X, Y, Time)** view the results with napari and -also process them with the `napari-stracking`_ plugin. - Here we adapt a workflow from the BoneJ2 paper (https://wellcomeopenresearch.org/articles/6-37) for use with napari-imagej. -For this use case we will analyze live cell wide-field microscopy data of HeLa cell nuclei (Hoechst stain), imaged every 30 minutes for 40 frames. -The data used in this use case is available in the `napari-imagej repository`_ on GitHub. - -.. image:: https://media.imagej.net/napari-imagej/trackmate_0.gif - :align: center - -| - napari Setup ---------------------- @@ -34,7 +20,7 @@ We can configure napari-imagej to use a Fiji installation by opening the setting Preparing and Opening the Data ------------------ -We will use the same data that was used in the BoneJ2 paper. Go ahead and download umzc_378p_Apteryx_haastii_head.tif.bz2 from doi:10.6084/m9.figshare.7257179 +We will use the same data that was used in the BoneJ2 paper. Go ahead and download umzc_378p_Apteryx_haastii_head.tif.bz2 from doi:10.6084/m9.figshare.7257179. Direct link: https://figshare.com/ndownloader/files/13369043 .. |ImageJ2| image:: ../../src/napari_imagej/resources/imagej2-16x16-flat.png From 74d075ffc6e7d4ebd6451b5f87c389b616893c97 Mon Sep 17 00:00:00 2001 From: Kyle Harrington Date: Fri, 2 Jun 2023 15:02:37 -0400 Subject: [PATCH 04/11] Add instructions to get the user through Anisotropy Currently upstream bugs are blocking: - area/volume fraction - ellipsoid factor --- doc/examples/bonej.rst | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/doc/examples/bonej.rst b/doc/examples/bonej.rst index d1779bb5..22eaff65 100644 --- a/doc/examples/bonej.rst +++ b/doc/examples/bonej.rst @@ -61,4 +61,15 @@ Now let's calculate the degree of anisotropy. Select the `inputImage` that corresponds to the theshold layer created previously. -Check the `Recommended minimums` box +Check the `Recommended minimums` box. +Enter `1.73` as the samplingInterval. + +This will output the degree of anisotropy measurement for the image. + +TODO +^^^^^^^^^^^^^^^^^^^^^^ + +Fix bugs and finish corresponding sections for: + +- Area/Volume Fraction +- Ellipsoid Factor From eec6e017f9f7bb214a9ffea4299e0c3c08d4a12e Mon Sep 17 00:00:00 2001 From: Kyle Harrington Date: Mon, 5 Jun 2023 11:14:41 -0400 Subject: [PATCH 05/11] Add pointer to issue documenting the blocks for finishing bonej2 --- doc/examples/bonej.rst | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/doc/examples/bonej.rst b/doc/examples/bonej.rst index 22eaff65..92d439d1 100644 --- a/doc/examples/bonej.rst +++ b/doc/examples/bonej.rst @@ -20,9 +20,7 @@ We can configure napari-imagej to use a Fiji installation by opening the setting Preparing and Opening the Data ------------------ -We will use the same data that was used in the BoneJ2 paper. Go ahead and download umzc_378p_Apteryx_haastii_head.tif.bz2 from doi:10.6084/m9.figshare.7257179. Direct link: https://figshare.com/ndownloader/files/13369043 - -.. |ImageJ2| image:: ../../src/napari_imagej/resources/imagej2-16x16-flat.png +We will use the same data that was used in the BoneJ2 paper. Go ahead and download umzc_378p_Apteryx_haastii_head.tif.bz2 from doi:10.6084/m9.figshare.7257179. Here is a direct link to the specific image: https://figshare.com/ndownloader/files/13369043 Opening Data in napari ^^^^^^^^^^^^^^^^^^^^^^ @@ -69,7 +67,7 @@ This will output the degree of anisotropy measurement for the image. TODO ^^^^^^^^^^^^^^^^^^^^^^ -Fix bugs and finish corresponding sections for: +Fix bugs (see https://github.com/imagej/napari-imagej/issues/261) and finish corresponding sections for: - Area/Volume Fraction - Ellipsoid Factor From 1da4cecc0bfccf7b8f9772f16e13f9fb7dc3a90c Mon Sep 17 00:00:00 2001 From: Kyle Harrington Date: Fri, 9 Jun 2023 12:17:31 -0400 Subject: [PATCH 06/11] Add Volume Fraction and Connectivitiy --- doc/examples/bonej.rst | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/doc/examples/bonej.rst b/doc/examples/bonej.rst index 92d439d1..8d5717ff 100644 --- a/doc/examples/bonej.rst +++ b/doc/examples/bonej.rst @@ -46,12 +46,12 @@ When the widget comes up, ensure that the layer that is selected is the result o 3. The result of thresholding is a Label layer, but we will convert it to an Image layer to work with BoneJ2. -Right click on the layer that was created by step 2 and select `Convert to Image`. +Right click on the layer that was created by step 2 and select `Convert to Image`. Processing Data in napari with BoneJ2 and napari-imagej ^^^^^^^^^^^^^^^^^^^^^^ -Now let's calculate the degree of anisotropy. +Calculating the degree of anisotropy: 1. In the napari-imagej search bar type `Anisotropy` @@ -64,10 +64,26 @@ Enter `1.73` as the samplingInterval. This will output the degree of anisotropy measurement for the image. -TODO -^^^^^^^^^^^^^^^^^^^^^^ -Fix bugs (see https://github.com/imagej/napari-imagej/issues/261) and finish corresponding sections for: +Calculating the Area/Volume Fraction: + +1. In the napari-imagej search bar type `Volume Fraction` + +2. Click `Run` + +Select the `inputImage` that corresponds to the theshold layer created previously. + +This will output the Bone Volume Fraction (BV/TV) measurement for the image. + + +Calculating the Connectivity: + +1. In the napari-imagej search bar type `Connectivity` + +2. Click `Run` + +Select the `inputImage` that corresponds to the theshold layer created previously. + +This will output the Euler characteristic and Conn.D for the image. + -- Area/Volume Fraction -- Ellipsoid Factor From 9ada5dd7a5fc9b4c64d4bc224e804b80431468e9 Mon Sep 17 00:00:00 2001 From: Kyle Harrington Date: Wed, 14 Jun 2023 09:05:54 -0400 Subject: [PATCH 07/11] Extend use case, add figures. --- doc/examples/bonej.rst | 125 +++++++++++++++++++++++++++++++++-------- 1 file changed, 103 insertions(+), 22 deletions(-) diff --git a/doc/examples/bonej.rst b/doc/examples/bonej.rst index 8d5717ff..5bd890a0 100644 --- a/doc/examples/bonej.rst +++ b/doc/examples/bonej.rst @@ -6,7 +6,10 @@ Here we adapt a workflow from the BoneJ2 paper (https://wellcomeopenresearch.org napari Setup ---------------------- -We will install one additional plugin to support this use case: https://github.com/haesleinhuepf/napari-segment-blobs-and-things-with-membranes +We will install one additional plugin to support this use case. Instructions for finding and installing a napari plugin are here: https://napari.org/stable/plugins/find_and_install_plugin.html + +Please follow these instructions to install the plugin ``napari-segment-blobs-and-things-with-membranes``. More information +on this plugin can be found here: https://github.com/haesleinhuepf/napari-segment-blobs-and-things-with-membranes. BoneJ2 Setup ---------------------- @@ -27,63 +30,141 @@ Opening Data in napari If you haven't already unzipped the file, then unzip the file. Once that is complete you can drag-and-drop the image onto napari to open it. +.. figure:: https://media.imagej.net/napari-imagej/bonej2_open_data.png + + A napari viewer showing the example image that we will be working with. + Processing Data in napari with nsbatwm ^^^^^^^^^^^^^^^^^^^^^^ Now we need to process the image. -1. First, we will blur the image to smooth intensity values and filter noise. +First, we will blur the image to smooth intensity values and filter noise. + +.. figure:: https://media.imagej.net/napari-imagej/bonej2_select_gaussian.png + + Selecting the Gaussian menu entry from the nsbatwm's Tools menu. + +1. Within napari's menus choose: ``Tools > Filtering / noise removal > Gaussian (scikit image, nsbatwm)`` + +.. figure:: https://media.imagej.net/napari-imagej/bonej2_gaussian_parameter.png + + Setting the parameters for the Gaussian. + +2. When the widget comes up, change the `sigma` value to 2 and ensure that the image layer is correctly set to the image that was opened. +Run the widget! -Within napari's menus choose: `Tools` > `Filtering / noise removal` > `Gaussian (scikit image, nsbatwm)` +Now we will threshold the image to make it binary. -When the widget comes up, change the `sigma` value to 2 and ensure that the image layer is correctly set to the image that was opened. +.. figure:: https://media.imagej.net/napari-imagej/bonej2_select_threshold.png -2. Now we will threshold the image to make it binary. + Selecting the thresholding algorithm developed by Li et al. + +1. Within napari's menus choose: ``Tools > Segmentation / binarization > Threshold (Li et al 1993, scikit image, nsbatwm)`` -Within napari's menus choose: `Tools` > `Segmentation / binarization` > `Threshold (Li et al 1993, scikit image, nsbatwm)` +2. When the widget comes up, ensure that the layer that is selected is the result of step 1. +Run the widget! -When the widget comes up, ensure that the layer that is selected is the result of step 1. +The result of thresholding is a Labels layer, but we will convert it to an Image layer to work with BoneJ2. -3. The result of thresholding is a Label layer, but we will convert it to an Image layer to work with BoneJ2. +.. figure:: https://media.imagej.net/napari-imagej/bonej2_convert_to_image.png -Right click on the layer that was created by step 2 and select `Convert to Image`. + Converting the Labels layer to an Image layer for processing in BoneJ2. + +1. Right click on the layer that was created by step 2 and select ``Convert to Image``. Processing Data in napari with BoneJ2 and napari-imagej ^^^^^^^^^^^^^^^^^^^^^^ Calculating the degree of anisotropy: -1. In the napari-imagej search bar type `Anisotropy` +1. In the napari-imagej search bar type ``anisotropy`` -2. Click `Run` +2. Click ``Run`` -Select the `inputImage` that corresponds to the theshold layer created previously. +3. Select the ``inputImage`` that corresponds to the theshold layer created previously. -Check the `Recommended minimums` box. -Enter `1.73` as the samplingInterval. +4. Check the ``Recommended minimums`` box. + +5. Enter ``1.73`` as the samplingInterval. + +.. figure:: https://media.imagej.net/napari-imagej/bonej2_anisotropy_parameters.png + + Setting the parameters of BoneJ2's Anisotropy command. This will output the degree of anisotropy measurement for the image. -Calculating the Area/Volume Fraction: +Calculating the fractal dimension: + +1. In the napari-imagej search bar type ``fractal dimension`` + +2. Click ``Run`` + +3. Select the ``inputImage`` that corresponds to the theshold layer created previously. + +4. Check the ``Automatic parameters`` box. + +.. figure:: https://media.imagej.net/napari-imagej/bonej2_fractal_dimension.png + + Setting the parameters of BoneJ2's fractal dimension command. + +This will output the fractal dimension of the image. -1. In the napari-imagej search bar type `Volume Fraction` -2. Click `Run` +Calculating the surface area: -Select the `inputImage` that corresponds to the theshold layer created previously. +1. In the napari-imagej search bar type ``surface area`` + +2. Click ``Run`` + +3. Select the ``inputImage`` that corresponds to the theshold layer created previously. + +.. figure:: https://media.imagej.net/napari-imagej/bonej2_surface_area.png + + Running BoneJ2's surface area command. + +This command may take some time, because it runs a computationally costly algorithm called +"Marching Cubes" that creates a surface mesh of the image before computing the surface area. +This will output the surface area of the thresholded regions. + + +Calculating the area/volume fraction: + +1. In the napari-imagej search bar type ``volume fraction`` + +2. Click ``Run`` + +3. Select the ``inputImage`` that corresponds to the theshold layer created previously. + +.. figure:: https://media.imagej.net/napari-imagej/bonej2_area_volume_fraction.png + + Running BoneJ2's area/volume fraction command. This will output the Bone Volume Fraction (BV/TV) measurement for the image. -Calculating the Connectivity: +Calculating the connectivity: + +1. In the napari-imagej search bar type ``connectivity`` + +2. Click ``Run`` -1. In the napari-imagej search bar type `Connectivity` +3. Select the ``inputImage`` that corresponds to the theshold layer created previously. -2. Click `Run` +.. figure:: https://media.imagej.net/napari-imagej/bonej2_connectivity.png -Select the `inputImage` that corresponds to the theshold layer created previously. + Running BoneJ2's connectivity command. This will output the Euler characteristic and Conn.D for the image. +The final measurements +^^^^^^^^^^^^^^^^^^^^^^ + +We have now quantified our image with a number of methods and can use our resulting +measurements in further scientific analysis! + +.. figure:: https://media.imagej.net/napari-imagej/bonej2_all_measurements.png + + The results table for all of the BoneJ2 measurements. From a6b6347daddc6c3035cde5a839a55afb127fb54e Mon Sep 17 00:00:00 2001 From: Kyle Harrington Date: Wed, 14 Jun 2023 09:08:09 -0400 Subject: [PATCH 08/11] Adjust formatting in BoneJ2 command section --- doc/examples/bonej.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/examples/bonej.rst b/doc/examples/bonej.rst index 5bd890a0..af1d6706 100644 --- a/doc/examples/bonej.rst +++ b/doc/examples/bonej.rst @@ -76,7 +76,7 @@ The result of thresholding is a Labels layer, but we will convert it to an Image Processing Data in napari with BoneJ2 and napari-imagej ^^^^^^^^^^^^^^^^^^^^^^ -Calculating the degree of anisotropy: +**Calculating the degree of anisotropy:** 1. In the napari-imagej search bar type ``anisotropy`` @@ -95,7 +95,7 @@ Calculating the degree of anisotropy: This will output the degree of anisotropy measurement for the image. -Calculating the fractal dimension: +**Calculating the fractal dimension:** 1. In the napari-imagej search bar type ``fractal dimension`` @@ -112,7 +112,7 @@ Calculating the fractal dimension: This will output the fractal dimension of the image. -Calculating the surface area: +**Calculating the surface area:** 1. In the napari-imagej search bar type ``surface area`` @@ -129,7 +129,7 @@ This command may take some time, because it runs a computationally costly algori This will output the surface area of the thresholded regions. -Calculating the area/volume fraction: +**Calculating the area/volume fraction:** 1. In the napari-imagej search bar type ``volume fraction`` @@ -144,7 +144,7 @@ Calculating the area/volume fraction: This will output the Bone Volume Fraction (BV/TV) measurement for the image. -Calculating the connectivity: +**Calculating the connectivity:** 1. In the napari-imagej search bar type ``connectivity`` From 1785c76302442a47e6eeb67ec0cbcb1affef23d1 Mon Sep 17 00:00:00 2001 From: Gabriel Selzer Date: Wed, 14 Jun 2023 08:51:18 -0500 Subject: [PATCH 09/11] Format underlines --- doc/examples/bonej.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/examples/bonej.rst b/doc/examples/bonej.rst index af1d6706..631736c7 100644 --- a/doc/examples/bonej.rst +++ b/doc/examples/bonej.rst @@ -4,7 +4,7 @@ Using BoneJ2 Here we adapt a workflow from the BoneJ2 paper (https://wellcomeopenresearch.org/articles/6-37) for use with napari-imagej. napari Setup ----------------------- +------------ We will install one additional plugin to support this use case. Instructions for finding and installing a napari plugin are here: https://napari.org/stable/plugins/find_and_install_plugin.html @@ -12,7 +12,7 @@ Please follow these instructions to install the plugin ``napari-segment-blobs-an on this plugin can be found here: https://github.com/haesleinhuepf/napari-segment-blobs-and-things-with-membranes. BoneJ2 Setup ----------------------- +------------ We need to first specify the endpoint that we will use to access BoneJ2. @@ -21,7 +21,7 @@ We can configure napari-imagej to use a Fiji installation by opening the setting **Note that napari must be restarted for these changes to take effect!** Preparing and Opening the Data ------------------- +------------------------------ We will use the same data that was used in the BoneJ2 paper. Go ahead and download umzc_378p_Apteryx_haastii_head.tif.bz2 from doi:10.6084/m9.figshare.7257179. Here is a direct link to the specific image: https://figshare.com/ndownloader/files/13369043 @@ -35,7 +35,7 @@ If you haven't already unzipped the file, then unzip the file. Once that is comp A napari viewer showing the example image that we will be working with. Processing Data in napari with nsbatwm -^^^^^^^^^^^^^^^^^^^^^^ +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Now we need to process the image. @@ -74,7 +74,7 @@ The result of thresholding is a Labels layer, but we will convert it to an Image 1. Right click on the layer that was created by step 2 and select ``Convert to Image``. Processing Data in napari with BoneJ2 and napari-imagej -^^^^^^^^^^^^^^^^^^^^^^ +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ **Calculating the degree of anisotropy:** From a79fec412aee40ec5bd7f9450b0cee48d330da4b Mon Sep 17 00:00:00 2001 From: Kyle Harrington Date: Wed, 14 Jun 2023 11:21:12 -0400 Subject: [PATCH 10/11] Update links --- doc/examples/bonej.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/examples/bonej.rst b/doc/examples/bonej.rst index 631736c7..11bda05a 100644 --- a/doc/examples/bonej.rst +++ b/doc/examples/bonej.rst @@ -1,15 +1,15 @@ Using BoneJ2 ======================================== -Here we adapt a workflow from the BoneJ2 paper (https://wellcomeopenresearch.org/articles/6-37) for use with napari-imagej. +Here we adapt a workflow from `the BoneJ2 paper `_ for use with napari-imagej. napari Setup ------------ -We will install one additional plugin to support this use case. Instructions for finding and installing a napari plugin are here: https://napari.org/stable/plugins/find_and_install_plugin.html +We will install one additional plugin to support this use case. Instructions for finding and installing a napari plugin are `here `_ Please follow these instructions to install the plugin ``napari-segment-blobs-and-things-with-membranes``. More information -on this plugin can be found here: https://github.com/haesleinhuepf/napari-segment-blobs-and-things-with-membranes. +on this plugin can be found `here `_ BoneJ2 Setup ------------ From 4089e42f77625407147bec71f146fd7200668c0e Mon Sep 17 00:00:00 2001 From: Gabriel Selzer Date: Fri, 16 Jun 2023 13:06:10 -0500 Subject: [PATCH 11/11] Minor edits to BoneJ use case --- doc/examples/bonej.rst | 91 ++++++++++++++++++++++++++---------------- 1 file changed, 56 insertions(+), 35 deletions(-) diff --git a/doc/examples/bonej.rst b/doc/examples/bonej.rst index 11bda05a..f2ee0154 100644 --- a/doc/examples/bonej.rst +++ b/doc/examples/bonej.rst @@ -6,29 +6,39 @@ Here we adapt a workflow from `the BoneJ2 paper `_ +We will install one additional napari plugin, `napari-segment-blobs-and-things-with-membranes `_, to support this use case. Instructions for finding and installing a napari plugin are `here `__ -Please follow these instructions to install the plugin ``napari-segment-blobs-and-things-with-membranes``. More information -on this plugin can be found `here `_ +To install ``napari-segment-blobs-and-things-with-membranes``, simply ensure that your napari environment is active and paste the following into your terminal: + +.. code-block:: bash + + pip install napari-segment-blobs-and-things-with-membranes + +Once the plugin has been installed correctly, ``napari-segment-blobs-and-things-with-membranes`` will appear as an option within the ``Plugins`` menu of napari, and the ``Tools`` menu will be populated with the various functions of the plugin. BoneJ2 Setup ------------ We need to first specify the endpoint that we will use to access BoneJ2. -We can configure napari-imagej to use a Fiji installation by opening the settings dialog and changing the ``imagej distribution_or_endpoint`` (described `here <../Configuration.html#imagej-directory-or-endpoint>`_). This example was created using an endpoint of ``sc.fiji:fiji:2.13.0+org.bonej:bonej-ops:MANAGED+org.bonej:bonej-plugins:MANAGED+org.bonej:bonej-utilities:MANAGED``. +We can configure napari-imagej to use BoneJ2 by opening the settings dialog and changing the ``imagej directory or endpoint`` (described `here <../Configuration.html#imagej-directory-or-endpoint>`__). Within the napari-imagej settings dialog, paste the following into the ``imagej directory or endpoint`` field, and click ``OK``: + +.. code-block:: + + sc.fiji:fiji:2.13.0+org.bonej:bonej-ops:MANAGED+org.bonej:bonej-plugins:MANAGED+org.bonej:bonej-utilities:MANAGED + **Note that napari must be restarted for these changes to take effect!** Preparing and Opening the Data ------------------------------ -We will use the same data that was used in the BoneJ2 paper. Go ahead and download umzc_378p_Apteryx_haastii_head.tif.bz2 from doi:10.6084/m9.figshare.7257179. Here is a direct link to the specific image: https://figshare.com/ndownloader/files/13369043 +We will use the same data that was used in the BoneJ2 paper. Go ahead and download ``umzc_378p_Apteryx_haastii_head.tif.bz2`` from ``doi:10.6084/m9.figshare.7257179``, linked directly `here `__. Opening Data in napari ^^^^^^^^^^^^^^^^^^^^^^ -If you haven't already unzipped the file, then unzip the file. Once that is complete you can drag-and-drop the image onto napari to open it. +Once you've unzipped the downloaded file, you can drag-and-drop the image onto napari to open it. .. figure:: https://media.imagej.net/napari-imagej/bonej2_open_data.png @@ -51,8 +61,9 @@ First, we will blur the image to smooth intensity values and filter noise. Setting the parameters for the Gaussian. -2. When the widget comes up, change the `sigma` value to 2 and ensure that the image layer is correctly set to the image that was opened. -Run the widget! +2. When the widget comes up, change the ``sigma`` value to ``2`` and ensure that the ``image`` layer is correctly set to the image that was opened. + +3. Run the widget! When the blurring is complete, a new ``Image`` layer will appear in the napari viewer. Now we will threshold the image to make it binary. @@ -63,101 +74,111 @@ Now we will threshold the image to make it binary. 1. Within napari's menus choose: ``Tools > Segmentation / binarization > Threshold (Li et al 1993, scikit image, nsbatwm)`` 2. When the widget comes up, ensure that the layer that is selected is the result of step 1. -Run the widget! -The result of thresholding is a Labels layer, but we will convert it to an Image layer to work with BoneJ2. +3. Run the widget! When the thresholding is complete, a new ``Labels`` layer will appear in the napari viewer. + +4. Right click on the new ``Labels`` layer and select ``Convert to Image``. This will allow us to pass the result, now an ``Image`` layer, to BoneJ2. .. figure:: https://media.imagej.net/napari-imagej/bonej2_convert_to_image.png Converting the Labels layer to an Image layer for processing in BoneJ2. -1. Right click on the layer that was created by step 2 and select ``Convert to Image``. Processing Data in napari with BoneJ2 and napari-imagej ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ **Calculating the degree of anisotropy:** -1. In the napari-imagej search bar type ``anisotropy`` +1. In the napari-imagej search bar type ``anisotropy``, and select the ``Anisotropy`` Command from the search results. -2. Click ``Run`` +2. Click ``Run``. 3. Select the ``inputImage`` that corresponds to the theshold layer created previously. -4. Check the ``Recommended minimums`` box. +4. Enter ``1.73`` as the samplingInterval. -5. Enter ``1.73`` as the samplingInterval. +5. Check the ``Recommended minimums`` box. + +6. Click ``OK``. + +This will output the degree of anisotropy measurement for the image. .. figure:: https://media.imagej.net/napari-imagej/bonej2_anisotropy_parameters.png Setting the parameters of BoneJ2's Anisotropy command. -This will output the degree of anisotropy measurement for the image. - **Calculating the fractal dimension:** -1. In the napari-imagej search bar type ``fractal dimension`` +1. In the napari-imagej search bar type ``fractal dimension``, and select the ``Fractal dimension`` Command from the search results. -2. Click ``Run`` +2. Click ``Run``. 3. Select the ``inputImage`` that corresponds to the theshold layer created previously. 4. Check the ``Automatic parameters`` box. +5. Click ``OK``. + +This will output the fractal dimension of the image. + .. figure:: https://media.imagej.net/napari-imagej/bonej2_fractal_dimension.png Setting the parameters of BoneJ2's fractal dimension command. -This will output the fractal dimension of the image. - **Calculating the surface area:** -1. In the napari-imagej search bar type ``surface area`` +1. In the napari-imagej search bar type ``surface area``, and select the ``Surface area`` Command from the search results. -2. Click ``Run`` +2. Click ``Run``. 3. Select the ``inputImage`` that corresponds to the theshold layer created previously. -.. figure:: https://media.imagej.net/napari-imagej/bonej2_surface_area.png +4. Click ``OK``. - Running BoneJ2's surface area command. - -This command may take some time, because it runs a computationally costly algorithm called +**Note:** This command may take some time, because it runs a computationally costly algorithm called "Marching Cubes" that creates a surface mesh of the image before computing the surface area. This will output the surface area of the thresholded regions. +.. figure:: https://media.imagej.net/napari-imagej/bonej2_surface_area.png + + Running BoneJ2's surface area command. + **Calculating the area/volume fraction:** -1. In the napari-imagej search bar type ``volume fraction`` +1. In the napari-imagej search bar type ``volume fraction``, and select the ``Area/Volume fraction`` Command from the search results. -2. Click ``Run`` +2. Click ``Run``. 3. Select the ``inputImage`` that corresponds to the theshold layer created previously. +4. Click ``OK``. + +This will output the Bone Volume Fraction (BV/TV) measurement for the image. + .. figure:: https://media.imagej.net/napari-imagej/bonej2_area_volume_fraction.png Running BoneJ2's area/volume fraction command. -This will output the Bone Volume Fraction (BV/TV) measurement for the image. - **Calculating the connectivity:** -1. In the napari-imagej search bar type ``connectivity`` +1. In the napari-imagej search bar type ``connectivity``, and select the ``Connectivity (Modern)`` Command from the search results. -2. Click ``Run`` +2. Click ``Run``. 3. Select the ``inputImage`` that corresponds to the theshold layer created previously. +4. Click ``OK``. + +This will output the Euler characteristic and Conn.D for the image. + .. figure:: https://media.imagej.net/napari-imagej/bonej2_connectivity.png Running BoneJ2's connectivity command. -This will output the Euler characteristic and Conn.D for the image. - The final measurements ^^^^^^^^^^^^^^^^^^^^^^