Differences between revisions 1 and 101 (spanning 100 versions)
⇤ ← Revision 1 as of 2023-03-06 21:57:23 →
Size: 27
Editor: JuanIglesias
Comment:
← Revision 101 as of 2026-10-28 17:25:24 → ⇥
Size: 12934
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
Describe PhotoTools here. = Photo Reconstruction Documentation =
<<TableOfContents>><<BR>><<BR>>

== Citation ==
If you use these tools in your analysis, please cite:

 * Gazula, H., Tregidgo, H.F., Billot, B., Balbastre, Y., Williams Ramirez, J., Herisse, R., Deden-Binder, L.J., Casamitjana, A., Melief, E.J., Latimer, C.S. and Kilgore, M.D., 2024. Machine learning of dissection photographs and surface scanning for quantitative 3D neuropathology. Elife, 12, p.RP91398. [[https://doi.org/10.7554/eLife.91398.4|doi]]

The machine learning slice imputation in the reconstruction is described in:

 * Crespo-Aguirre, M., Williams-Ramirez, J., Zemlyanker, D., Hu, X., Deden-Binder, L.J., Herisse, R., Montine, M., Connors, T.R., Mount, C., !MacDonald, C.L., Keene, C.D., Latimer, C.S., Oakley, D.H., Hyman, B.T., Lawry-Aguila, A. and Iglesias, J.E., 2026. Improving neuropathological reconstruction fidelity via AI slice imputation. Acta Neuropathologica Communications. [[https://doi.org/10.1186/s40478-026-02451-3|doi]]

Automatic segmentation model trained using nnUNet:

 * Williams Ramirez, J., Zemlyanker, D., Deden-Binder, L., Herisse, R., Garcia Pallares, E., Gopinath, K., Gazula, H., Mount, C., Kozanno, L.N., Marshall, M.S., Connors, T.R., Frosch, M.P., Montine, M., Oakley, D.H., Mac Donald, C.L., Keene, C.D., Hyman, B.T., Fischl, B. and Iglesias, J.E., 2026. A public generalizable AI tool for automated segmentation of coronal brain tissue slabs for 3D neuropathology. PLOS One, 21(8), p.e0355740. [[https://doi.org/10.1371/journal.pone.0355740|doi]]
 * Isensee, F., Jaeger, P.F., Kohl, S.A., Petersen, J. and Maier-Hein, K.H., 2021. nnU-Net: a self-configuring method for deep learning-based biomedical image segmentation. Nature methods, 18(2), pp.203-211.

[[https://www.youtube.com/watch?v=wo5meYRaGUY|Click here for a video with an overview of the method]]<<BR>> {{attachment:video_screenshot.png||width="666"}} <<BR>><<BR>>

== Purpose ==
This manual provides an end-to-end guide for using the tools available on FreeSurfer to reconstruct dissection photographs of brain slabs into a 3D-reconstruction for quantitative analysis. Reconstructions are done by registering photographs to a 3D reference like an MRI, a post-mortem surface scan, or an atlas. The guide touches on acquisition of surface scans prior to slabbing, preparing tissue slabs for gross photography, and how to preprocess photographs using the dissection_photo graphical user interface.<<BR>><<BR>>

== Requirements ==
 * The latest FreeSurfer development version sourced in your terminal.
 * Model files (downloaded once):
  * the [[https://ftp.nmr.mgh.harvard.edu/pub/dist/lcnpublic/dist/dissection_photo_model/photo_imputation_unet.pth|reconstruction model]] downloaded, into `$FREESURFER_HOME/models`
 * A CUDA enabled graphics card is optional: segmentation and reconstruction are much faster with one.

== Overview ==
 1. '''Acquire a 3D reference''' either a surface scan or an MRI. Without one, slabs are registered to an atlas.
 1. '''Photograph the tissue slabs'''
 1. '''Preprocess the photos on the dissection photo GUI'''
 1. '''Reconstruct the 3D volume'''
 1. '''Downstream analysis of photographs'''

= Part 1: Acquisition =
== Surface scanning ==
A surface scan of the specimen, taken before it is slabbed after the cerebellum is sectioned. The full scanning protocol is available on its own page: '''[[PhotoTools Surface Scanning|Surface Scanning Protocol]]'''.

Summary on key requirements of a reference mesh:

 * The cerebellum removed: it is not on the slabs, so including it in the scan leads to an incorrect reconstruction.
 * The sides of the specimen captured.
 * A watertight mesh, saved as `.stl`. Small holes in the initial point-cloud due to deep sulci are fine - these will be covered by the meshing process.

<<BR>>

== Preparing Slabs ==
The following guidelines should be followed when preparing slab images for optimal results. <<BR>>

== Guidelines for Brain Slab Image Acquisition ==
There are some important requirements for the photographic setup of the brain slabs to ensure the best results.

Use a high-contrast background that stands out in uniform contrast to the brain slabs, such as a solid black background. This will make slabs are easier to segment downstream. Using a complex background with color similar to your brain slabs, will lead to a more manual intervention such as having to manually trace contours, which is not only time-consuming but also non-reproducible.<<BR>>
|| {{attachment:17_low_constrast.png||height="266"}} || {{attachment:18_high_contrast.png||height="266"}} ||
||Difficult to segment low contrast background. ||Easy to segment high contrast background. ||




Additionally, all tissue block faces must be facing the same direction. All slices should be either from an anterior or a posterior view. Note if slabs are from the posterior view, an extra flag,

'''--photos_of_posterior_side''' must be used for the final reconstruction command.

When a single slice produces multiple tissue blocks, they should be placed as similar to the original anatomy as possible. For example, after acquiring slices from the frontal pole, the initial blocks corresponding to the temporal lobe will often be detached from the main block. The following figure shows a) Proper anatomical placement of tissue and, b) Tissue placed too far apart, which is not anatomically accurate.

{{attachment:19_slab_placement.png||height="483",width="667"}} <<BR>>''Tissue slab placement a) Properly placed tissue b) Tissue placed in a non-anatomical manner.''<<BR>>

Another example of difficult tissue placement can be the corpus callosum. In the following figure, we see a good example setup with high contrast for the background and good lighting. However, the placement of the corpus callosum on the rightmost slab is incorrect, which will negatively affect volumetric estimates of the third ventricle.

{{attachment:20_incorrect_tissue_placement.png||height="333",width="659"}} <<BR>> <<BR>>

== Markers for pixel and perspective corrections ==
To calibrate pixel size, we will need landmarks with known distances in between them to be provided by the user. The minimum requirement is a ruler, which provides us with two discrete landmarks. This enables rough This method is preferable for legacy images that only have a ruler for reference.

{{attachment:21_twoPoint.jpeg||height="382",width="664"}} <<BR>>

'''''Tip''''': It is better to use landmarks that are as far apart as possible, as the relative error when manually setting the reference in pixels per millimeter decreases with greater distances.

A more effective setup involves four landmarks placed the corners of a rectangle of known dimensions. This enables us to correct for both pixel size and perspective. In the example below, we can easily tell that the 4 points marked on the grid define a rectangle of dimensions 170x200 mm.

{{attachment:22_fourPoint.png||height="561",width="659"}} <<BR>>

The optimal scenario is to have 4 points defined by fiducial markers with highly salient features. This enables our software to automatically recognize the fiducials, which minimizes human interaction, reducing time and maximizing reproducibility. We '''strongly''' recommend that you print these set fiducials and place them on the corners of the board.

{{attachment:23_fiducials.png||height="439",width="416"}} <<BR>>

'''''Tip''''': For best results, affix these fiducials to a small piece of rubber/wood/plastic that lifts them X mm above the board, where X is the thickness of your typical brain slice. Lifting the fiducial minimizes error due to the surface of the brain slice not being at the same distance as the plane of the board surface, but rather a few millimeters above it.

{{attachment:24_fiducialTissue.png||height="460",width="674"}} <<BR>>

The fiducial form the four corners of our corrected image; hence all tissue should be within the rectangle created from the four fiducial corners. The following image shows slab photos where the fiducials were not placed sufficiently apart.

{{attachment:25_tissueSpace.png||height="404",width="685"}} <<BR>>

By drawing a rectangle with all fiducial markers, it is clear that much of the tissue lies outside of the pixel-corrected region.

{{attachment:26_tissueBox.png||height="403",width="683"}} <<BR>>

In summary, here is an example of what an optimal photographic setup would look like, including the uniform, high-contrast background and provided fiducials located at known distances, and consistent lighting on all slabs.

{{attachment:27_goodContrast.png||height="478",width="676"}} <<BR>>

'''''Tip''''': It does not matter if slabs are not presented on a grid, as long as the distance between the fiducials is known. The software will draw digital rulers for your images later pixel-correction.<<BR>><<BR>>



= Part 2: Prerprocessing Photographs with the Dissection Photo App =
The dissection photo app has five principal windows for each subject: '''Add photos''', '''Correction''', '''Segmentation''', '''Connected components''' and '''Reconstruction'''. The step bar at the top of the window shows which step is being done, users can click any backtrack by clicking any of the previous steps at any time, alternatively the house icon to return to the Projects screen with a summary of all reconstructions done or in process. For each project work is saved as you go, so the can can be closed at any time to later pick up where you left off.

Before continuing, make sure the development version of Freesurfer is properly sourced, you have downloaded the model weights, and have set the NNUNET_MODEL_DIR as an environment variable pointing to the segmentation model before continuing with the tutorial. To start the application use command *dissection_photo_2* <<BR>>

== Projects Page ==
Each specimen corresponds to a '''project''': a folder which will be populated with the outputs from all steps. The project home contains a summary of all projects and their progress.

{{attachment:ds2_00_projects.png||width="600"}} <<BR>> ''Projects Home screen'''

* To start processing a new batch of dissection photographs click on '''New Project'''.
* Open a project to continue where you left off or backtrack to any completed steps.
''' Tip ''' For advaced users, the gear icon can be used to change which resources are used by the automatic segmentation model, covered in [[#Automatic segmentation settings|automatic segmentation settings]].

After naming a project you will be prompted to save a folder of the same name. It is in this folder that the outputs of all steps will be stored.

== Directory Structure ==
For each project the following directory structure will be populated with all outputs.
||'''Folder / file'''||'''Contents'''||
||`photos/`|| Copy of the original photographs||
||`deformed/`||Pixel-corrected photos||
||`mask/`||Binary tissue masks||
||`connected_components/`||Label maps per slab||
||`recon/`||The 3D-photo reconstruction||

== Step 1. Add photographs ==
1. Drag and drop a folder containing dissection photographs, or click '''Upload Images'''.
1. Select the photographs that should be used for the reconstruction. This can be used to omit repeat photographs, dissection photographs of cerebellar tissue, or pre-slabbing gross photographs. Double click on any image in the grid for a larger preview.
1. If you have or would like to create a calibration file to automate pixel correction, click on '''+ Add a calibration file (optional)''' and follow steps in [[#Making a calibration file|making a calibration file]] and then [[#Prospective Correction (Using fiducial markers and calibration file) | Prospective Correction]]
1. Click '''Get Started'''

=== Optional: Making a calibration file ===

== Step 2: Pixel Correction ==

=== Prospective Correction (Using fiducial markers and calibration file) ===

=== Retrospective Correction (Using a spatial reference within the photographs) ===

== Step 3: Binary Segmentation ==
=== Automatic Segmentation Settings ===

== Step 4: Slab Connected Components ==

== Step 5: Photo Reconstruction ==
Please see our separate page on the command [[mri_3d_photo_recon]]

<<BR>>

= Part 3: Downstream Tasks =
== Photo-Synthseg Segmentation ==
The 3D reconstructed stacks can be segmented with SynthSeg using the flag --photo. Please see [[https://surfer.nmr.mgh.harvard.edu/fswiki/SynthSeg|the wiki page for SynthSeg]] for further information.
|| {{attachment:43_synthseg_photo.jpg||height="400"}} || {{attachment:44_synthseg_parc.jpg||height="400"}} ||


'''Example for running SynthSeg on a Left Hemisphere''' <<BR>>

 . mri_synthseg \
 . --i ./recon/photo_recon.mgz \
 . --o ./recon/photo_recon_synthseg.mgz \
 . --photo left \
 . --parc

Photo Reconstruction Documentation



Citation

If you use these tools in your analysis, please cite:

  • Gazula, H., Tregidgo, H.F., Billot, B., Balbastre, Y., Williams Ramirez, J., Herisse, R., Deden-Binder, L.J., Casamitjana, A., Melief, E.J., Latimer, C.S. and Kilgore, M.D., 2024. Machine learning of dissection photographs and surface scanning for quantitative 3D neuropathology. Elife, 12, p.RP91398. doi

The machine learning slice imputation in the reconstruction is described in:

  • Crespo-Aguirre, M., Williams-Ramirez, J., Zemlyanker, D., Hu, X., Deden-Binder, L.J., Herisse, R., Montine, M., Connors, T.R., Mount, C., MacDonald, C.L., Keene, C.D., Latimer, C.S., Oakley, D.H., Hyman, B.T., Lawry-Aguila, A. and Iglesias, J.E., 2026. Improving neuropathological reconstruction fidelity via AI slice imputation. Acta Neuropathologica Communications. doi

Automatic segmentation model trained using nnUNet:

  • Williams Ramirez, J., Zemlyanker, D., Deden-Binder, L., Herisse, R., Garcia Pallares, E., Gopinath, K., Gazula, H., Mount, C., Kozanno, L.N., Marshall, M.S., Connors, T.R., Frosch, M.P., Montine, M., Oakley, D.H., Mac Donald, C.L., Keene, C.D., Hyman, B.T., Fischl, B. and Iglesias, J.E., 2026. A public generalizable AI tool for automated segmentation of coronal brain tissue slabs for 3D neuropathology. PLOS One, 21(8), p.e0355740. doi

  • Isensee, F., Jaeger, P.F., Kohl, S.A., Petersen, J. and Maier-Hein, K.H., 2021. nnU-Net: a self-configuring method for deep learning-based biomedical image segmentation. Nature methods, 18(2), pp.203-211.

Click here for a video with an overview of the method
video_screenshot.png

Purpose

This manual provides an end-to-end guide for using the tools available on FreeSurfer to reconstruct dissection photographs of brain slabs into a 3D-reconstruction for quantitative analysis. Reconstructions are done by registering photographs to a 3D reference like an MRI, a post-mortem surface scan, or an atlas. The guide touches on acquisition of surface scans prior to slabbing, preparing tissue slabs for gross photography, and how to preprocess photographs using the dissection_photo graphical user interface.

Requirements

  • The latest FreeSurfer development version sourced in your terminal.

  • Model files (downloaded once):
  • A CUDA enabled graphics card is optional: segmentation and reconstruction are much faster with one.

Overview

  1. Acquire a 3D reference either a surface scan or an MRI. Without one, slabs are registered to an atlas.

  2. Photograph the tissue slabs

  3. Preprocess the photos on the dissection photo GUI

  4. Reconstruct the 3D volume

  5. Downstream analysis of photographs

Part 1: Acquisition

Surface scanning

A surface scan of the specimen, taken before it is slabbed after the cerebellum is sectioned. The full scanning protocol is available on its own page: Surface Scanning Protocol.

Summary on key requirements of a reference mesh:

  • The cerebellum removed: it is not on the slabs, so including it in the scan leads to an incorrect reconstruction.
  • The sides of the specimen captured.
  • A watertight mesh, saved as .stl. Small holes in the initial point-cloud due to deep sulci are fine - these will be covered by the meshing process.


Preparing Slabs

The following guidelines should be followed when preparing slab images for optimal results.

Guidelines for Brain Slab Image Acquisition

There are some important requirements for the photographic setup of the brain slabs to ensure the best results.

Use a high-contrast background that stands out in uniform contrast to the brain slabs, such as a solid black background. This will make slabs are easier to segment downstream. Using a complex background with color similar to your brain slabs, will lead to a more manual intervention such as having to manually trace contours, which is not only time-consuming but also non-reproducible.

17_low_constrast.png

18_high_contrast.png

Difficult to segment low contrast background.

Easy to segment high contrast background.

Additionally, all tissue block faces must be facing the same direction. All slices should be either from an anterior or a posterior view. Note if slabs are from the posterior view, an extra flag,

--photos_of_posterior_side must be used for the final reconstruction command.

When a single slice produces multiple tissue blocks, they should be placed as similar to the original anatomy as possible. For example, after acquiring slices from the frontal pole, the initial blocks corresponding to the temporal lobe will often be detached from the main block. The following figure shows a) Proper anatomical placement of tissue and, b) Tissue placed too far apart, which is not anatomically accurate.

19_slab_placement.png
Tissue slab placement a) Properly placed tissue b) Tissue placed in a non-anatomical manner.

Another example of difficult tissue placement can be the corpus callosum. In the following figure, we see a good example setup with high contrast for the background and good lighting. However, the placement of the corpus callosum on the rightmost slab is incorrect, which will negatively affect volumetric estimates of the third ventricle.

20_incorrect_tissue_placement.png

Markers for pixel and perspective corrections

To calibrate pixel size, we will need landmarks with known distances in between them to be provided by the user. The minimum requirement is a ruler, which provides us with two discrete landmarks. This enables rough This method is preferable for legacy images that only have a ruler for reference.

21_twoPoint.jpeg

Tip: It is better to use landmarks that are as far apart as possible, as the relative error when manually setting the reference in pixels per millimeter decreases with greater distances.

A more effective setup involves four landmarks placed the corners of a rectangle of known dimensions. This enables us to correct for both pixel size and perspective. In the example below, we can easily tell that the 4 points marked on the grid define a rectangle of dimensions 170x200 mm.

22_fourPoint.png

The optimal scenario is to have 4 points defined by fiducial markers with highly salient features. This enables our software to automatically recognize the fiducials, which minimizes human interaction, reducing time and maximizing reproducibility. We strongly recommend that you print these set fiducials and place them on the corners of the board.

23_fiducials.png

Tip: For best results, affix these fiducials to a small piece of rubber/wood/plastic that lifts them X mm above the board, where X is the thickness of your typical brain slice. Lifting the fiducial minimizes error due to the surface of the brain slice not being at the same distance as the plane of the board surface, but rather a few millimeters above it.

24_fiducialTissue.png

The fiducial form the four corners of our corrected image; hence all tissue should be within the rectangle created from the four fiducial corners. The following image shows slab photos where the fiducials were not placed sufficiently apart.

25_tissueSpace.png

By drawing a rectangle with all fiducial markers, it is clear that much of the tissue lies outside of the pixel-corrected region.

26_tissueBox.png

In summary, here is an example of what an optimal photographic setup would look like, including the uniform, high-contrast background and provided fiducials located at known distances, and consistent lighting on all slabs.

27_goodContrast.png

Tip: It does not matter if slabs are not presented on a grid, as long as the distance between the fiducials is known. The software will draw digital rulers for your images later pixel-correction.

Part 2: Prerprocessing Photographs with the Dissection Photo App

The dissection photo app has five principal windows for each subject: Add photos, Correction, Segmentation, Connected components and Reconstruction. The step bar at the top of the window shows which step is being done, users can click any backtrack by clicking any of the previous steps at any time, alternatively the house icon to return to the Projects screen with a summary of all reconstructions done or in process. For each project work is saved as you go, so the can can be closed at any time to later pick up where you left off.

Before continuing, make sure the development version of Freesurfer is properly sourced, you have downloaded the model weights, and have set the NNUNET_MODEL_DIR as an environment variable pointing to the segmentation model before continuing with the tutorial. To start the application use command *dissection_photo_2*

Projects Page

Each specimen corresponds to a project: a folder which will be populated with the outputs from all steps. The project home contains a summary of all projects and their progress.

ds2_00_projects.png
Projects Home screen

* To start processing a new batch of dissection photographs click on New Project. * Open a project to continue where you left off or backtrack to any completed steps. Tip For advaced users, the gear icon can be used to change which resources are used by the automatic segmentation model, covered in automatic segmentation settings.

After naming a project you will be prompted to save a folder of the same name. It is in this folder that the outputs of all steps will be stored.

Directory Structure

For each project the following directory structure will be populated with all outputs.

Folder / file

Contents

photos/

Copy of the original photographs

deformed/

Pixel-corrected photos

mask/

Binary tissue masks

connected_components/

Label maps per slab

recon/

The 3D-photo reconstruction

Step 1. Add photographs

1. Drag and drop a folder containing dissection photographs, or click Upload Images. 1. Select the photographs that should be used for the reconstruction. This can be used to omit repeat photographs, dissection photographs of cerebellar tissue, or pre-slabbing gross photographs. Double click on any image in the grid for a larger preview. 1. If you have or would like to create a calibration file to automate pixel correction, click on + Add a calibration file (optional) and follow steps in making a calibration file and then Prospective Correction 1. Click Get Started

Optional: Making a calibration file

Step 2: Pixel Correction

Prospective Correction (Using fiducial markers and calibration file)

Retrospective Correction (Using a spatial reference within the photographs)

Step 3: Binary Segmentation

Automatic Segmentation Settings

Step 4: Slab Connected Components

Step 5: Photo Reconstruction

Please see our separate page on the command mri_3d_photo_recon


Part 3: Downstream Tasks

Photo-Synthseg Segmentation

The 3D reconstructed stacks can be segmented with SynthSeg using the flag --photo. Please see the wiki page for SynthSeg for further information.

43_synthseg_photo.jpg

44_synthseg_parc.jpg

Example for running SynthSeg on a Left Hemisphere

  • mri_synthseg \
  • --i ./recon/photo_recon.mgz \
  • --o ./recon/photo_recon_synthseg.mgz \
  • --photo left \
  • --parc

PhotoTools (last edited 2026-10-28 18:50:43 by JonWilliamsRamirez)