Abstract
The number and distribution of follicles in each growth stage provide a reliable readout of ovarian health and function. Leveraging techniques for three-dimensional imaging of ovaries in toto has the potential to uncover total, accurate ovarian follicle counts. Due to the size and holistic nature of these images, counting oocytes is time consuming and difficult. The advent of machine-learning algorithms has allowed for the development of ultra-fast, automated methods to analyze microscopy images. In recent years, these pipelines have become more accessible to non-specialists. We used these tools to create OoCount, a high-throughput, open-source method for automatic oocyte segmentation and classification from fluorescent three-dimensional microscopy images of whole mouse ovaries using a deep-learning convolutional neural network–based approach. We developed a fast tissue-clearing and imaging protocol to obtain three-dimensional images of whole-mount mouse ovaries. Fluorescently labeled oocytes from three-dimensional images were manually annotated in Napari to develop a training dataset. This dataset was used to retrain StarDist using a convolutional neural network within DL4MicEverywhere to automatically label all oocytes in the ovary. In a second phase, we utilize Accelerated Pixel and Object Classification, a Napari plugin, to sort oocytes into growth stages. Here, we provide an end-to-end pipeline for producing high-quality three-dimensional images of mouse ovaries and obtaining follicle counts and staging. We demonstrate how to customize OoCount to fit images produced in any lab. Using OoCount, we obtain oocyte counts from each growth stage in the perinatal and adult ovary, improving our ability to study ovarian function and fertility.
Keywords: ovary, oocyte, mouse, machine learning, bioimage analysis, microscopy, follicle counting
This protocol introduces OoCount, a high-throughput, open-source method for automatic oocyte segmentation and classification from fluorescent 3D microscopy images of whole mouse ovaries using a machine-learning-based approach.
Graphical Abstract
Graphical Abstract.
Introduction
Mammalian females are born with a finite supply of oocytes; thus, reproductive longevity is determined by the number of oocytes endowed at birth and the rate of depletion of this pool. Ovarian follicles, the functional units of the ovary, are composed of an oocyte surrounded by granulosa cells. During each reproductive cycle, a small number of primordial follicles, the quiescent follicles that make up the ovarian reserve, are activated and progress through growth stages. Eventually only a small subset of growing follicles in each cycle (or a single one in humans) will reach ovulation, while others undergo atresia [1–3]. The number and distribution of ovarian follicles in each growth stage have provided the field of ovarian biology with a reliable readout of ovarian health and function [4, 5]. This quantification is typically performed by extrapolating total follicle counts from histological sections of the ovary. However, due to the heterogeneous nature of ovarian tissue and variations in sectioning and extrapolation methods, reported follicle counts vary greatly between studies and can often be inaccurate [5, 6]. The recent development of techniques for three-dimensional (3D) imaging of ovaries in toto has opened the possibility of obtaining robust, accurate, and near-absolute follicle counts [7–17].
Three-dimensional imaging of ovaries in toto also provides the field with crucial spatial information on the regulation of follicle activation and growth, alongside improved follicle counts. However, extracting biological information from these large image datasets is challenging and time consuming. Fortunately, the advent of machine-learning algorithms allowed the rapid development of ultra-fast, automated methods to analyze large amounts of microscopy data [18–20]. In recent years, more and more groups have created user-friendly programming notebooks and code that provide biologists with accessible ways to utilize machine learning in their research [21–27]. We leveraged tools including Napari [28], DL4MicEverywhere [22], StarDist [27], and Accelerated Pixel and Object Classification (APOC) [29] to create OoCount. We developed a fast tissue-clearing and spinning-disk confocal-based imaging protocol to obtain 3D images of whole-mount perinatal and adult mouse ovaries. We trained the existing StarDist convolutional neural network (CNN) to automatically label oocytes through the entire perinatal and adult mouse ovary. In a second phase, we trained APOC, a machine-learning-based classifier, to classify labeled oocytes and sort them into growth stages. With OoCount, users can efficiently obtain reliable counts of oocytes in each growth stage in the perinatal and adult ovary, improving our ability to study ovarian function and fertility.
Overview of methods
The following protocol details the steps users can take to implement OoCount for analysis of follicle distribution in the perinatal or adult ovary. In steps 1–4, we provide a complete workflow for producing 3D images of the ovary to use with OoCount. In steps 5–9, we detail the steps to utilize OoCount to segment and classify oocytes from 3D images of perinatal and adult ovaries. To segment (identify) all oocytes in a 3D image, we created custom StarDist models for perinatal and adult ovaries (https://www.mckeylab.com/oocount) [27]. To classify oocytes into growth stages, we provide instructions on training APOC for perinatal and adult ovaries [29]. If the images generated in a different lab are incompatible or do not yield satisfactory results with our version of OoCount, we have also included step 9, which details the tools and approaches required to optimize OoCount for different types of images.
If using ovaries dissected from mice postnatal day (P) 8 or younger, we suggest following the “perinatal protocol” for tissue preparation and immunostaining. If using ovaries dissected from mice P9 and older, we suggest following the “adult protocol” for preparation and immunostaining. Our perinatal version of OoCount only distinguishes between growing and quiescent follicles, while our adult version of OoCount distinguishes primordial, primary, secondary, and antral follicles. This is important to note before using this workflow.
The entire pipeline was developed using samples from CD-1 mice (Charles River Laboratories). The use of animals to develop this method was conducted in accordance with protocols approved by the Institutional Animal Care and Use Committee of the University of Colorado Anschutz Medical Campus (IACUC protocol #1262) and Duke University (IACUC protocol #A089-20-04 9 N).
In this manuscript, we provide protocols for the following steps:
Sample preparation. Ovaries are dissected from perinatal or adult mice, fixed, and dehydrated before immunostaining.
Immunostaining. Ovaries are processed for fluorescent immunostaining to visualize oocytes. The reagents and antibodies required for this step are listed in Tables 1 and 2 and Table S1.
Tissue clearing and preparation for imaging. Perinatal ovaries are embedded in a CUBIC-based clearing gel. Adult ovaries are cleared using ethyl cinnamate (ECi). In both cases, ovaries are mounted for imaging in 3D-printed coverslip holders, which we colloquially called “coverslip’n’slide” (https://www.mckeylab.com/3d-prints).
Imaging. Mounted cleared ovaries are imaged using a spinning disk confocal microscope.
Setting up the OoCount workflow and Python environment. Anaconda Navigator is downloaded onto the computer used for image analysis, and a new Python environment is created for OoCount. Napari is installed, and images are loaded in for analysis.
Segmenting oocytes with StarDist. Using the OoCount-StarDist model, oocytes are segmented from the image.
Classifying oocytes with APOC. Oocytes are classified into growth stages using a marker of follicle activation.
Obtaining total counts. The total number of oocytes in each growth stage is quantified and displayed.
Creating a custom StarDist model. If the current OoCount model is not effective for images produced using different imaging setups or methods, we have provided the tools required to retrain OoCount.
Table 1.
Summary of reagents required for staining and clearing perinatal ovaries for OoCount analysis
| Reagent | Component | Target Concentration | Catalog Number | Supplier | Preparation | Purpose | |
|---|---|---|---|---|---|---|---|
| Perinatal Whole Mount Immunofluorescence | Methanol gradient | Methanol PBS |
75%, 50%, 25% 25%, 50%, 75% |
423,950,040 see below |
Fisher Scientific See below |
40 mL made in a 50 mL conical tube with 1× PBS as the diluent | Dehydration |
| 1× PBS | 10× PBS Ultra-pure water |
1× PBS Diluent |
70,011,069 10–977-023 |
Gibco Invitrogen |
For a 500 mL solution make a 50 mL aliquot of 10× PBS and bring to 500 mL with ultra-pure water. Invert to mix. |
Rehydration | |
| PBS 10% Tx-100 | Triton X-100 1× PBS |
10% Diluent |
X100-500ML 70,011,069 |
Sigma-Millipore Gibco |
Mix 10 ml Triton X-100 with 90 mL 1× PBS. | Working stock | |
| PBS 1% Tx-100 | Triton X-100 1X PBS |
1% Diluent |
X100-500ML 70,011,069 |
Sigma-Millipore Gibco |
Dilute 5 mL of 10% Tx-100 working stock 40 mL with 1× PBS. | Diluent for block solution | |
| PBS 0.1% Tx-100 | Triton X-100 1X PBS |
0.1% Diluent |
X100-500ML 70,011,069 |
Sigma-Millipore Gibco |
Use 10% Tx-100 solution as a working stock. Then, make a 0.1% solution by making a 500 μL aliquot of 10% Tx-100 and bring to 50 mL with 1X PBS. |
Permeabilization | |
| Block solution | Horse serum PBS 1% Tx-100 |
10% Diluent |
26–050-088 See above |
Gibco See above |
Prepare a 10 mL solution by making a 1 mL aliquot 100% horse serum and bring to 10 mL with PBS 1% Tx-100. Invert to mix, store at 4°C for up to 1 week. | Block | |
| CUBIC R2 Solution | Urea Sucrose Triethanolamine HyPure Water |
25% 50% 10% × (g) to 100% |
501,368,682 501,368,582 90,279-500ML 10–977-023 |
Fisher Scientific Fisher Scientific Sigma-Millipore Fisher Scientific |
Because CUBIC solutions are very viscous, they are prepared as %wt/volume, using a scale rather than volume measurements. For a 100 g solution, put a beaker on a scale and combine: 25 g urea, 50 g sucrose, and 10 g triethanolamine; then, fill to 100 g with HyPure water. Scale up or down depending on use. Store at room temperature. | Clearing reagent | |
| 2% CUBIC Agarose in CUBIC R2 | Agarose R2 |
2% Diluent |
50–255-228 See above |
Fisher Scientific See above |
For a 100 mL solution, weigh 2 g of agarose and add to an Erlenmeyer flask. Bring to 100 mL with an R2 reagent and heat gently until agarose goes into solution. Make 2 mL aliquots, and store at room temperature until needed. (Note: do not heat in a microwave; a heatblock with a stir bar or 50 mL in a falcon tube is recommended) |
Mounting medium and clearing reagent |
Table 2.
Summary of reagents required for staining and clearing adult ovaries for OoCount analysis
| Reagent | Component | Target concentration | Catalog number | Supplier | Preparation | Purpose | |
|---|---|---|---|---|---|---|---|
| Adult Whole Mount Immunofluorescence | Isopropyl alcohol | Isopropyl alcohol PBS |
75%, 50%, 25% 25%, 50%, 75% |
67–63-0 See below |
Fisher Scientific See below |
Make solutions using the combinations indicated. For example, for a 10 mL solution of 75% isopropyl alcohol: add 7.5 mL isopropanol to 2.5 mL of 1× PBS. Do the same for the other solutions. |
Dehydration |
| 1× PBS | 10× PBS Ultra-Pure Water |
1× PBS | 70,011,069 10–977-023 |
Gibco Invitrogen |
For a 500 mL solution, make a 50 mL aliquot of 10× PBS and bring to 500 mL with ultra-pure water. Invert to mix. | Rehydration | |
| PBS 10% Tx-100 | Triton X-100 1X PBS |
10% Diluent |
X100-500ML 70,011,069 |
Sigma-Millipore Gibco |
Mix 10 mL Triton X-100 with 90 mL 1× PBS. | Working stock | |
| PBS 0.2% Tx-100 | Triton Tx-100 1x PBS |
0.2% Diluent |
X100-500ML 70,011,069 |
Sigma-Millipore Gibco |
Dilute 1 mL aliquot of 10% Tx-100 working stock with 49 mL of 1× PBS. | Diluent for block solution | |
| Permeabilizing solution | Glycine PBS 0.2% Tx-100 |
2.3% Diluent |
G7126-500G See Above |
Sigma-Millipore See above |
For a 50 mL solution, add 1.15 g glycine to a 50 mL conical and bring to 50 mL with PBS 0.2% Tx-100. Invert to mix. | Permeabilization | |
| Block solution | Horse serum PBS 0.2% Tx-100 |
10% Diluent |
26–050-088 See above |
Gibco See above |
For a 10 mL solution, make a 1 mL aliquot of 100% horse serum and bring to 10 mL with PBS 0.2% Tx-100. | Block | |
| Heparin wash solution (PTwH) | Heparin PBS 0.2% Tx-100 |
10 μg/mL Diluent |
H339-50KU See above |
Sigma-Millipore See above |
For a 10 mL solution, make a 5 mL aliquot of PBS 0.2% Tx-100 and add 10 μL of a 10 mg/mL heparin stock solution. Bring to 10 mL final volume with PBS 0.2% Tx-100 and invert to mix. |
Wash solution —heparin reduces antibody background | |
| Antibody solution | Horse serum Heparin wash solution |
10% Diluent |
26–050-088 See above |
Gibco See above |
For a 10 mL solution, make a 5 mL aliquot of heparin wash solution and add 1 mL 100% horse serum, fill to 10 mL with heparin wash solution and invert to mix. | Prevent non-specific signal | |
| Ethyl cinnamate | N/A | N/A | 112,372–100G | Sigma-Aldrich | Use as is. | Clearing reagent |
An overview of these protocol steps is presented in Figure 1. All reagents and solutions are listed in Tables 1 and 2.
Figure 1.
Overview of OoCount workflow. Schematic of the OoCount workflow including how to generate high-quality 3D images of perinatal and adult ovaries to use within the computational pipeline. Made with BioRender. Folts, L. (2025) https://BioRender.com/8sqz1py.
All materials are listed in Table S2. All equipment and software used are listed in Table S3.
Sample preparation
Perinatal (Pn) samples
Unless otherwise stated, use 500 μL of solution at each step. For more detailed instructions on the dissection of ovarian tissue from perinatal mice, see the method outlined in the JoVE encyclopedia of experiments [30].
Pn.1.1 Euthanize female pups according to approved institutional regulations and dissect ovaries in 1× phosphate-buffered saline (PBS). Transfer the ovaries into a 1.5 mL tube with forceps.
Pn.1.2 Add 4% paraformaldehyde (PFA)/PBS to fix. Incubate for 30 min rocking at room temperature.
Pn.1.3 Following one quick rinse in 1× PBS, wash ovaries with 1× PBS for 20 min rocking at room temperature, or leave them in PBS at 4°C overnight without rocking.
Pn.1.4 Dehydrate ovaries in an increasing methanol (MeOH)/PBS gradient: 25%, 50%, 75%, and 100% MeOH each for 15 min rocking at room temperature. Store ovaries in 100% methanol at −20°C until ready to use. We recommend storing samples in 100% methanol at −20°C for no longer than 6 months. We noticed an increase in autofluorescence with samples older than 6 months.
Adult (Ad) samples
Unless otherwise stated, use 1 mL of solution at each step. For more detailed instructions on the dissection of ovarian tissue from adult mice, we suggest the method outlined by Converse and colleagues [31].
Ad.1.1 Euthanize female mice according to approved institutional regulations and dissect ovaries in PBS. Transfer them into a 1.5 mL tube with forceps. Ovaries should be removed from the bursa before further processing.
Ad.1.2 Add 4% PFA/PBS to fix. Incubate for 1 h at room temperature rocking.
Ad.1.3 Following one quick rinse in 1× PBS, wash ovaries with 1× PBS for 20 min rocking at room temperature, or leave them in 1× PBS at 4°C overnight without rocking.
Ad.1.4 Dehydrate the ovaries in an increasing isopropanol (IPA)/PBS gradient: 30%, 50%, 70%, and 100% IPA for 15 min each rocking at room temperature. Store ovaries in 100% IPA at −20°C until ready to use. We recommend storing samples in 100% IPA at −20°C for no longer than 6 months. We noticed an increase in autofluorescence with samples older than 6 months.
Immunostaining
We recommend the following steps to perform whole-mount immunofluorescence staining on perinatal and adult mouse ovaries. We have provided detailed protocols in Supplementary protocols 1 (perinatal) and 2 (adult), and regularly updated versions can be found at https://www.mckeylab.com/protocols. In addition, we provide a list of solutions and reagents needed in Table S2. We used commercially available antibodies against DDX4 (raised in rabbit) to label oocytes and against NR5A2 (raised in goat) to label granulosa cells (listed in Table S1). While these are the recommended antibodies, we have also used several other commercially available DDX4 antibodies to label oocytes (Figure S1A) and alternative activation markers (Figure S1B) with this workflow.
Note: We serendipitously found that, in the perinatal ovary but not in the adult ovary, the NR5A2 goat antibody labeled the nuclei of oocytes in the medullary region of the ovary, in addition to labeling nuclei of activated granulosa cells. To determine whether the NR5A2 signal in the oocyte was specific to active follicles in the perinatal ovary, we co-stained with antibodies against GDF-9, a well-characterized oocyte activation marker (Figure S1B). We manually counted GDF-9-positive oocytes and determined whether each of these displayed the NR5A2 signal in the oocyte and/or in the granulosa cells surrounding the oocyte (Figure S1C). We found that GDF-9 and NR5A2 labeling overlapped in medullary oocytes at a rate of 80% and that the NR5A2 signal was present in 100% of the granulosa cells surrounding the GDF-9-positive oocytes (Figure S1C and D). While NR5A2 is known to be expressed in the granulosa cells of active follicles [32–34], we have not confirmed that the NR5A2 protein is actually present in the nuclei of activated oocytes. Nonetheless, we have leveraged this unexpected staining as a marker of active oocytes in the perinatal ovary in our pipeline. However, it is important to note that the NR5A2 signal is only in active granulosa cells in the adult ovary. If the user prefers a different marker of oocyte activation, such as GDF-9, we recommend using the rabbit GDF-9 antibody combined with the goat hVASA (human DDX4) antibody to label all oocytes (Table S1).
Perinatal samples
Start with samples that have been fixed and dehydrated according to Steps Pn.1.1–1.4. Ovaries must be stored for at least one night in 100% methanol at −20°C. Unless otherwise stated, use 500 μL of solution at each step. This section of the protocol takes a total of 3 days.
Pn.2.1: Rehydrate the samples in a decreasing MeOH/PBS gradient: 75%, 50%, and 25% MeOH, 1× PBS for 15 min each rocking at room temperature.
Pn.2.2 Remove PBS and permeabilize for 20 min with PBS 0.1% Tx-100 rocking at room temperature.
Pn.2.3 Remove PBS 0.1% Tx-100 and incubate with freshly prepared block solution rocking at room temperature for 1 h rocking. If at this point the ovaries are still in the ovarian capsule, carefully remove the ovarian capsule with fine forceps. This will allow for optimal ovary permeability.
Pn.2.4 Remove the block solution and replace with a primary antibody solution (1°AS). Primary antibodies should be diluted according to Table S2 in 250 μL block solution. Incubate in 1°AS overnight at 4°C without rocking.
Pn.2.5 Remove 1°AS and wash samples three times for 20 min each with PBS 0.1% Tx-100 rocking at room temperature.
Pn.2.6 Remove PBS 0.1% Tx-100 and replace with a secondary antibody solution (2°AS). For 2°AS, secondary antibodies should be diluted at 1:500 in 250 μL of block solution and the solution should be filtered using a syringe-driven 22 μm filter before adding to the samples (Table S2). Place the tube with the samples in a dark box. Incubate in filtered 2°AS overnight at 4°C without rocking.
Pn.2.7 Remove 2°AS and wash samples three times 20 min with PBS 0.1% Tx-100 at room temperature rocking. Wash once with PBS for 15 min at room temperature rocking. Store samples at 4°C until ready to mount for imaging.
Note: For best results, we recommend mounting as soon as possible after staining. We have noted that the immunofluorescence signal is more stable in the mounting medium than in PBS, and mounted slides can be stored at 4°C in the dark for up to 5 days before imaging.
Adult samples
Start with samples that have been fixed and dehydrated according to Steps Ad.1.1–1.4. Ovaries must be stored for at least one night in 100% IPA at −20°C. Unless otherwise stated, use 1 mL of solution at each step. This section of the protocol takes 7–8 days.
Ad.2.1: Rehydrate the samples in a decreasing IPA/PBS gradient: 75%, 50%, and 25% IPA for 20 min each at room temperature on a rocker. Wash for 20 min in PTx.2.
Ad.2.2 Remove PTx.2 and replace with the permeabilizing solution. Incubate overnight at 37°C without rocking.
Ad.2.3 Remove the permeabilizing solution and incubate in a freshly prepared block solution at 37°C without rocking for 6 h.
Ad.2.4 Remove block solution and incubate with 1°AS. Antibodies should be diluted according to Table S1 in a 250 μL block solution. Incubate in 1°AS for 3 nights at 37°C without rocking.
Ad.2.5 Remove 1°AS and wash samples three times for 1 h with heparin wash solution (PTwH) rocking at room temperature.
Ad.2.6 Remove PTwH and incubate with 2°AS. Antibodies should be diluted at 1:500 in a 250 μL block solution. Once prepared, filter 2°AS using a syringe-driven filter. Incubate in filtered 2°AS for 2 nights at 37°C without rocking. After this step, the samples should be kept in the dark as much as possible.
Ad.2.7 Remove 2°AS and wash samples three times for 1 h each with PTwH rocking at room temperature.
Ad.2.8 Remove PTwH and dehydrate samples using an increasing IPA/PBS gradient: 30%, 50%, 70%, and 100% IPA for 20 min each rocking at room temperature. Proceed to tissue clearing (section Ad.3) immediately after this step.
Tissue clearing and mounting samples for imaging
Perinatal samples
CUBIC R2 agarose will be used to clear and mount the perinatal samples for imaging. While other clearing methods should be compatible with the OoCount pipeline, CUBIC R2 agarose presents many advantages, including excellent transparency of the tissue, use of non-toxic and affordable chemicals, ease of tissue mounting for imaging with different microscopes (slide based or chamber based), and rapid clearing [17]. Before performing this step, be sure to prepare 2 mL aliquots of the CUBIC R2 agarose and have a 3D-printed coverslip holder (coverslip’n’slide) prepared (Figure 2-1) (the recipe for CUBIC R2 agarose can be found in Table 1; the file for the coverslip’n’slide can be found at https://www.mckeylab.com/3d-prints) [35]. Materials are listed in Table S2. Detailed visual instructions for this step are illustrated in Figure 2.
Figure 2.
Mounting and preparing perinatal ovaries for imaging. 1. Print a coverslip’n’slide and gather supplies for mounting the samples. 2. Apply nail polish to the edges of a coverslip. 3. Attach the coverslip onto the coverslip’n’slide. 4. Using forceps, gently move the samples onto the coverslip. 5. Arrange the samples on the coverslip. 6. Using a tissue, remove the excess liquid from the coverslip. 7. Slowly pipe the melted CUBIC R2 agarose around and in between the samples. Samples should be surrounded completely by agarose (as indicated by the top arrow) and not partially covered (as indicated by the bottom arrow) for best results. 8. Add a coverslip on top of the samples.
Pn.3.1 Place an aliquot of CUBIC R2 agarose at 95°C in a heat block 10 min before mounting the samples for clearing and imaging. Note: Avoid leaving the CUBIC R2 agarose at 95°C for too long, as it will burn and become yellow and slightly opaque.
Pn.3.2 Secure a coverslip onto the coverslip’n’slide by carefully lining the outer edges of the coverslip using clear coat nail polish. Do not use too little as this will make an imperfect seal, but not too much as this could refract the laser and make imaging your sample more difficult (Figure 2-2, 3). Arrange the samples in the middle of the coverslip using forceps. Carefully remove any remaining PBS with tissue paper (Figure 2-4, 5, 6).
Pn.3.3 Using a pipet, slowly pipe approximately 100–200 μL of the melted CUBIC R2 agarose around and in between the samples, being careful not to add the hot CUBIC R2 agarose solution directly onto the tissue. Eventually, the pools of liquid CUBIC R2 agarose will come together to form a continuous blob with all tissue samples encased. Forceps can be used to gently nudge the agarose to cover the sample. Make sure that there is a good border of agar around your sample (Figure 2-7).
Pn.3.4 Place a coverslip over the samples and press lightly (Figure 2-8). Note: The amount of pressure applied on the coverslip will alter the 3D volume of the tissue. More pressure will decrease the time to acquire a Z-stack, but the rendered 3D images will look flatter.
Adult samples
Ethyl cinnamate will be used to clear the adult ovaries. While ECi is not a hazardous material, inhalation of the vapors should be avoided. Ethyl cinnamate on adult samples yields excellent transparency of the tissue, the chemicals used are non-toxic and affordable, and the tissue is easily mounted for imaging with different microscopes (slide based or chamber based) [17]. Materials are listed in Table S2. Detailed visual instructions for this step are illustrated in Figure 3.
Figure 3.
Mounting and preparing adult ovaries for imaging. 1. Print a coverslip’n’slide and gather materials for mounting the samples. Note the filling inlets on the coverslip’n’slide indicated with arrows. 2. Apply super glue around the edges of a coverslip and attach it to the coverslip’n’slide. 3. Load a syringe with sealant for more precise control over application. 4. Using the syringe, create a chamber using sealant by lining the edges of the coverslip. 5. Arrange the samples on the coverslip. 6. Apply a coverslip to the top of the sealant, creating a chamber. 7. Gently push on the top coverslip until it touches the samples. 8. Using a pipet, fill the chamber with ECi. 9. Plug the filling inlets with sealant. 10. Allow to cure for 1 h before imaging.
Note that adult ovaries require a thicker coverslip chamber in the 3D-printed coverslip holder (3 mm for adult instead of 2 mm for perinatal). The file for the 3 mm coverslip’n’slide can be found at https://www.mckeylab.com/3d-prints. The thickness of the coverslip’n’slide coverslip chamber can be changed to fit the size of the tissue being imaged (“Modular coverslip’n’slide” file at https://www.mckeylab.com/3d-prints).
Ad.3.1 Replace 100% IPA with ECi, making sure to fill the entire tube or vial with ECi to avoid oxidation of the tissue, which prevents clearing. Invert the tube gently about 10 times; do not shake. The tube may be stored in the dark at room temperature until ready for imaging. Wait for the sample to be completely clear before proceeding to mounting and imaging (this can take a few hours).
Ad.3.2 Secure a base coverslip on the thick coverslip’n’slide using superglue. Attaching the coverslip with superglue is critical for mounting the ECi-cleared samples. This creates a strong enough seal to prevent ECi from leaking out onto the objectives of the microscope and prevents skin contact with the ECi. Allow this to cure for several minutes. Arrange the samples on the base coverslip using forceps (Figure 3-1, 2).
Ad.3.3 Create a chamber using a silicon or epoxy sealant along the edge of the base coverslip. Do not put the sealant over the filling inlets (Figure 3-3). For precise control of the sealant, we recommend squeezing the sealant into the back of a 10 mL syringe (Figure 3-3, 4) and using the syringe to apply the sealant to create a chamber. Transfer the samples onto the coverslip using forceps (Figure 3-5). Gently place a coverslip on top of the sealant, making sure that the coverslip makes contact with the samples (Figure 3-6, 7).
Ad.3.4 Fill the chamber with ECi with a pipet through the filling inlet. Fill the chamber as much as possible. Avoid creating bubbles over the samples (Figure 3-8).
Ad.3.5 Plug the inlets with sealant and allow 1 h for the sealant to cure before imaging (Figure 3-9). Make sure that the chamber is well sealed and that ECi is not leaking by placing the slide on a clean tissue paper (Figure 3-10).
Imaging
Imaging can be achieved on a variety of microscopes capable of imaging through large tissues (adult mouse ovaries are typically between 500 μm and 1 mm and perinatal mouse ovaries are about 200 μm). Optimize microscope settings for the fastest acquisition that allows for visualization of the smallest primordial follicles. We recommend a maximum Z interval of 5 μm to ensure that primordial follicles are captured on at least two optical slices. To generate the images presented in this protocol, we used an Oxford Instruments Andor Dragonfly 202 Spinning Disk Confocal microscope with a 40 μm disk pinhole (Oxford Instruments, Abingdon, UK), and a Leica DMi8 microscope stand (Leica Microsystems, Wetzlar, Germany) with an Applied Scientific Instrumentation Piezo stage controller (Applied Scientific Instrumentation, OR, USA). Images of perinatal or adult ovaries were acquired using a 25× water immersion (NA 0.95) or 10× dry (NA 0.45) objective (Leica Microsystems, Wetzlar, Germany), respectively. Images were captured by an Andor Zyla 4.2 plus sCMOS camera (Oxford Instruments Andor, Abingdon, UK). We used a high-power laser engine (HLE) equipped with 637 and 561 nm lasers to visualize Alexa Fluor dye 647 (DDX4) and Cy3 (NR5A2), respectively. We used high laser powers (>10%) and low exposure times (<100 ms) to optimize for fast acquisition. Perinatal or adult samples were imaged with a Z-interval of 1 or 3 μm, respectively. The tissue clearing achieved by following steps 1–4 will produce 3D images that allow for visualization through the entire perinatal or adult ovary (Figure 4, Videos 1 and 2). Note that this pipeline is not ideally suited for laser scanning confocal systems, as these will significantly increase acquisition time and sample photobleaching. We highly recommend using a spinning disk or single-plane illumination microscopy (SPIM/light sheet).
Figure 4.
High-resolution visualization of perinatal and adult ovaries in toto. Our immunostaining and clearing protocol is optimized for visualization of oocytes labeled with DDX4 antibodies through the entire perinatal and adult ovary, including high-resolution visualization of primordial follicles. Top optical slice is closest to the objective, while the bottom optical slice is furthest from the objective. The panel furthest to the right shows a zoom in on primordial follicles visualized in perinatal and adult ovaries. Scale bars: 150 μm.
Note: While steps 1–4 are recommended for OoCount, we expect the pipeline to be compatible with other clearing and imaging methods. For example, we have also successfully applied OoCount to adult samples cleared with the iDISCO (immunolabeling-enabled three-dimensional imaging of solvent-cleared organs) method and imaged with a lightsheet microscope.
Setting up the OoCount workflow and Python environment
We recommend installing the required OoCount dependencies via Anaconda. Anaconda is a distribution of the Python programming language for scientific computing. Anaconda simplifies the installation of Python packages and the creation of “virtual environments,” which consist of a directory structure containing its own Python interpreter, standard library, and specific versions of additional dependencies required for a particular project. Anaconda provides a graphical user interface named “Anaconda Navigator,” which can be used to create virtual environments and install dependencies. Anaconda also provides a command-line tool named “conda,” which can be used as an alternative to the graphical user interface.
The following instructions assume Anaconda and Anaconda Navigator have already been installed. Download Anaconda Navigator at https://www.anaconda.com/anaconda-navigator. Note: The computational portion of the pipeline is not different for analysis of adult and perinatal samples. Unless otherwise indicated, the steps will be the same.
5.1 Open Anaconda Navigator and click on Environments > Create to make a new environment for OoCount. Type in a name for the environment (e.g., OoCount) and select packages Python 3.9.7; then, click “create.” Click the new environment in the side panel to activate it, and click the “play” button to open the terminal.
Note: If you prefer not to use Anaconda Navigator, you can also create the conda environment directly in the terminal by running the following commands:
$ conda create -n OoCount -c conda-forge python=3.9
$ conda activate OoCount
This requires conda to be installed on your machine, installation instructions can be found at https://conda.io/projects/conda/en/latest/user-guide/install/index.html.
5.2 Once your OoCount environment is installed and activated, enter the following commands, one by one in the terminal:
$ pip install tensorflow==2.12
$ pip install matplotlib==3.8.2
$ pip install tifffile==2023.9.26
$ pip install tqdm==4.66.1
$ pip install imageio==2.33.0
$ pip install numba==0.58.1
$ pip install scikit-image==0.22.0
$ pip install napari==0.4.18
$ pip install stardist-napari==2022.12.6
$ pip install napari-accelerated-pixel-and-object-classification==0.14.1
$ pip install devbio-napari==0.10.1
This will install the specific versions of the packages used for OoCount into your conda environment.
Note: If using a Windows computer with CUDA-compatible Graphics Processing Unit (GPU) and you want to use GPU acceleration, you will need to install CUDAtoolkit:
$ pip install cudatoolkit=10.2
5.3 After installation, re-open Anaconda Navigator. Click on Environments > OoCount > open with terminal (Video 3). When the terminal opens, enter “napari” and a Napari window will open. Napari (Napari contributors, 2019) is a free and open-sourced Python-based interactive viewer for multi-dimensional images. Napari can be used for state-of-the-art computational image analysis tasks comparable to FiJi [36] or Imaris (Bitplane, Inc).
5.4 To import images into Napari, the file can be dragged in or uploaded by clicking on File > Open. Import images as single-channel tiffs or import multichannel tiffs and split channels in Napari. Once opened, the screen should resemble Figure 5. A brief overview of Napari can be seen in Video 4, but further instructions and tutorials on how to use the Napari viewer can be found at https://napari.org/stable/index.html.
Figure 5.
Opening images in Napari. Example screenshot of a multichannel image open in Napari. In a mouse perinatal ovary, DDX4 labels all oocytes and NR5A2 labels the nuclei of active oocytes and growing granulosa cells.
5.5 Before continuing, download the OoCount deliverables from our lab website (https://mckeylab.com/oocount). This folder contains the necessary files and code needed for this workflow, in addition to example data. Save this folder in a place that will be accessible for later. How and when the deliverables will be used is explained in later sections.
StarDist-OoCount model to segment mouse oocytes
Before beginning this section, it is important to set up an organizational system to save images and labels. Create a new folder and then create two subfolders within it, one named “Images'' and the other named “Masks.” The “Images” folder should contain all the images you wish to segment, and the “Masks” folder is where you will later save the labels layers after running StarDist-OoCount.
To obtain a near-absolute count of oocytes in a 3D image of the ovary, the oocytes must be segmented from the image. In image analysis, object segmentation is the process of identifying specific objects or regions of interest within an image. StarDist is a segmentation tool that can run as a plugin in Napari (StarDist-Napari plugin) [27]. While StarDist was originally created to segment fluorescent nuclei, we retrained the “3D_demo” StarDist model to segment oocytes from 3D images of perinatal and adult ovaries. The trained 3D StarDist models segment objects within the 3D projection, thus each object (oocyte) is only segmented once. Our process for retraining StarDist is detailed in the “Creating a custom StarDist model” section. We created two retrained StarDist models called StarDist-OoCount_Perinatal and StarDist-OoCount_Adult. To assess the efficacy of the training, we used training validation and training loss plots automatically rendered by the DL4MicEverywhere StarDist 3D training notebook (Figure S2A) [22, 23]. In addition, we followed the quality control prompts of the training notebook, which perform comparisons between ground truth annotations and model prediction (Figure S2B). In this context, ground truth annotations are manual annotations of each oocyte in the images, similar to those used to create the training dataset. These comparisons yielded average intersection over union (IoU) values of 0.77 for OoCount_Perinatal, and 0.71 for OoCount_Adult. It is worth noting that the IoU is calculated as a pixel match between ground truth and prediction, so if the shape of the predicted label doesn’t match the shape of the manual annotation, the IoU decreases, even though the oocyte was accurately recognized as an object to label. Thus, the IoU is a conservative estimate of the efficacy of our StarDist-OoCount models.
After running StarDist-OoCount on an image in Napari, an output layer with labels will be created. The labels layer of the image contains the segmented oocytes.
6.1 Once an image with DDX4-labeled oocytes is imported into Napari, click Plugins > Napari-StarDist. A StarDist panel should open on the right side of the Napari window.
6.2 Keep all the default settings, except for those changed in Video 5. The Image Axis, Model Type, Custom Model, and Number of Tiles will need to be changed. For perinatal ovaries: Image Axis is ZXY, Model Type is Custom 2D/3D Model, Custom Model is FILE NAME, and Number of Tiles is 1,6,6 (Video 5). For adult ovaries: Image Axis is ZXY, Model Type is Custom 2D/3D Model, Custom Model is FILE NAME, and Number of Tiles is 1,10,10 (Video 5). After these settings have been adjusted, click Run. Note: The “number of tiles” setting is a z, y, x vector, and will need to be adjusted based on computational power and the size of the image to segment. If StarDist crashes when using these suggested values, consider increasing the number of tiles (e.g., 2,12,12) to reduce the computational load for StarDist. The scaling setting should be changed if the scale of the image to segment is significantly different from those that were used to train StarDist. For our retrained models, the voxel size for the perinatal training images was z = 0.996 μm, y = 0.603 μm, x = 0.603 μm and for the adult images, it was z = 3 μm, y = 0.241 μm, x = 0.241 μm. For optimal segmentation accuracy, the image to segment must be scaled to match the voxel size of the training data. The scaling setting takes an (z,y,x) vector. For example, if an image has a voxel size of z = 0.996 μm, y = 1.21 μm, x = 1.21 μm, the x and y values of the image should be divided by 2 to match the StarDist-OoCount_perinatal model. In this case, the scaling setting should be set to (1, 0.5, 0.5). Alternatively, it is possible to resample the image before running StarDist. Note: The adult and perinatal models that we generated differ in scaling because perinatal images were captured with a 25× objective, while adult images were captured with a 10× objective. We recommend you use the model that is closest to the scale of the image to segment, as it may provide better results than the “age-matched” model.
Once the image has been segmented by OoCount-StarDist, it should resemble the output in Figure 6 and Video 5, where each oocyte is segmented with a different colored label. If there are missegmented oocytes, these can be corrected by following the steps in Video 6. Save the labels layer in the “Masks" folder with the same file name as the image.
Figure 6.
Segmenting oocytes from 3D images of ovaries. The StarDist-OoCount model segments oocytes (labeled using DDX4) from 3D images of perinatal and adult (not shown here) ovaries.
Training APOC to classify oocytes
Once oocytes have been segmented from the image, they can be classified based on their growth stage. When performing object classification, objects within an image are assigned to certain classes or categories based on their features. Accelerated Pixel and Object Classifier (APOC) [29] is a classifier plugin for Napari [37]. APOC uses machine learning to train based on user input, making it easy-to-use and extremely versatile. Based on factors such as the expression of the activation marker NR5A2, pixel number, and signal intensity, APOC will classify oocyte labels created by StarDist-OoCount into growth stages with minimal training. For perinatal ovaries, oocytes are classified into one of two states: quiescent or active. In adult ovaries, we demonstrate how oocytes can be classified into one of four growth stages: primordial, primary, secondary, and antral. This analysis uses the segmentation result from StarDist-OoCount (mask file) and the individual channel images for the marker that will be used for classification (image file). In our case, we use DDX4 as a marker to segment all oocytes, and NR5A2 as a marker of follicle activation for classification (more specific guidance on follicle classification can be found in Figure S3). Any specific marker that distinguishes active from quiescent follicles should work. Alternatively, classification can be done for features other than growth or quiescence. For example, users may opt to use a cell death marker to quantify atresia or use expression of a protein of interest to quantify how many oocytes are expressing it. For additional information and support on using APOC in Napari, we recommend reading the user guide (https://github.com/haesleinhuepf/napari-accelerated-pixel-and-object-classification).
Note: Only NR5A2 signal within cells was used to classify oocytes. Bright acellular speckles are background from the antibody staining.
7.1 In Napari, open an image with the NR5A2 channel and the corresponding mask from StarDist (Figure 7 and Video 7). In Napari, click Plugins > Napari-accelerated-pixel-and-object-classification > object classification. An APOC panel should appear on the right side of the screen.
Figure 7.
APOC classification in perinatal ovaries. When doing classification in APOC, the NR5A2 image (seen in the top-left panel) overlayed with the DDX4 labels (seen in the top-right panel) will be useful for determining activation of oocytes to assist in sparse annotations (seen in the bottom-left panel). After training, APOC classifies quiescent follicles (seen in the bottom-right panel in lines closer to the surface of the ovary) and active follicles (seen in the bottom-right panel in dots and line closer to the middle of the ovary) in the perinatal mouse ovary.
7.2 Create a new labels layer, and name it “annotation.” This new layer will hold your annotations for each class. Use the paintbrush tool to paint over the StarDist mask (Figure 7 and Video 7), associating a unique label value with each growth stage class. For example, in perinatal ovaries, use label #1 for quiescent follicles and label #2 for active follicles. APOC works with sparse annotation, so there is no need to paint over every oocyte. Be sure to move through the Z-stacks and annotate oocytes at different depths and in different regions of the ovary. There is no need to annotate on every single Z slice, but it is recommended to annotate at least 10 oocytes, and to annotate on slices from the dorsal, middle and ventral faces, as signal intensity and oocyte distribution typically changes throughout the volume. Repeat this for each class. Note: On the StarDist labels layers, change the “contour” value to 1 or 2 to toggle contour view instead of fill. This will allow you to see the underlying NR5A2 staining.
7.3 Once oocytes of all classes have been sparsely annotated, APOC can be run (Video 8). Be sure to save the classifier file where it is accessible for future use, as the same classifier file can be used on other ovaries within the same batch of images that the classifier was trained on. Set the tree depth to 5 and the number of trees to 100. We obtain satisfactory classification results by selecting the following features for classification: Mean intensity, pixel count, standard deviation intensity, shape, centroid position, touching neighbor count, and average distance to touching neighbors. However, we recommend testing different combinations of features depending on your classification goals. Click Train. Note: APOC extracts features based on the portion of the native image that is covered by the StarDist label of that object (oocyte) and uses these features to classify objects. These features include fluorescence intensity, area, volume, distance to nearest neighbors, etc. Since StarDist labels only cover the oocyte, only oocyte fluorescence and its close vicinity are taken into account. Thus, the number of granulosa layers is not taken into account to distinguish between primary and early secondary follicles, but rather the size of the oocyte and the number of nearest neighbors, as primary follicles tend to be closer together since they have fewer granulosa cells surrounding them.
7.4 Inspect the classification for errors. Using the same labels as 7.2, paint over errors in the annotation layer. Do not correct every erroneous label, so that APOC can attempt to correct them during retraining. Click Train again. APOC may need to be trained and corrected several times. Once APOC is achieving satisfactory classification, save the final APOC prediction output layer. Note: APOC will likely not classify oocytes with 100% accuracy but this can be manually corrected. Reopen the classification layer in Napari over the image with the NR5A2 channel and StarDist labels. The classification layer can now be edited using the label eraser and brush tools to correct any misclassified oocytes (Video 9).
Once APOC has classified the oocytes, the output should resemble Figure 7 for perinatal ovaries, and Figure 8 for adult images. Classifier files created in APOC can reliably be used for all images within a single imaging batch. However, APOC may need to be retrained for new batches of images.
Figure 8.
APOC classification in adult ovaries. When classifying follicles from the adult ovary, we recommend using the NR5A2 image layer (seen in the top-left panel) overlayed with the DDX labels (seen in the top-right panel) to determine the stage of the follicles. Use this to sparsely annotate the labels (seen in the bottom-left panel). After training, APOC will classify follicles into primordial, primary, secondary, and antral.
Getting total counts
To produce final oocyte counts, we used the Napari-gpt plugin (https://github.com/royerlab/napari-chatgpt) to generate code that would output oocyte counts by class [38]. With this code, for each unique label produced by StarDist, the label number assigned to it by APOC is determined and counted (e.g., 1 for quiescent and 2 for active).
8.1 Once the segmented oocytes from StarDist are classified into growth stages by APOC, open the file “Napari-OoCountResult.py” in any text editor (we use Visual Studio Code, Microsoft Corporation). Copy the code provided and paste it into the Napari console (Video 10). Click enter to run the code. Follow the prompts to obtain an output with the total number of oocytes and the number of oocytes in each growth stage (Figure 9). The output is generated in a comma-separated format that can be copied into a spreadsheet. The code used to generate total counts was written with the assistance of Omega, a Napari plugin that utilizes ChatGPT to process and analyze microscopy images [38]. We recommend Omega for assistance in writing code if users require a different output than the one our code generates.
Figure 9.
OoCount quantifies oocytes in 3D images of ovaries. (A) Representative data from the OoCount workflow showing the total number of oocytes, the number of quiescent oocytes, and the number of active oocytes from four P3 ovaries. (B) Representative data from the OoCount workflow showing the total number of oocytes and the number of oocytes at each growth stage in three 3-month-old ovaries.
Traditionally, follicle counts are obtained from histological sections. In the “gold standard” method, follicles are counted and scored on one 5–10 μm section every five sections. The resulting “sparse” totals are then extrapolated by multiplying the number of follicles in each class by 5, thereby accounting for the skipped sections, to obtain a final count [5, 6]. To compare OoCount with traditional follicle counting, we applied the OoCount pipeline and an adaptation of the manual counting method to the same Z-stacks. To emulate the sparse sectioning and extrapolation, we first condensed Z-stacks composed of 3 μm optical Z-slices into Z-stacks of 9 μm “sections". We then ran StarDist-OoCount on the condensed image to label all oocytes and counted the number of labeled oocytes on every 5th “section”. Finally, the sparse total was “corrected” by multiplying by 5 (Figure S4A) [39]. While results obtained through our adapted extrapolation method were similar to previously published manual counts [5], the different methods, OoCount and “extrapolation,” when applied to the same 3-month-old CD-1 mouse ovaries, yielded different results (Figure S4A). In one case, the OoCount pipeline labeled approximately 2000 oocytes, whereas the extrapolation method indicated over 7000 oocytes. Since StarDist-OoCount labels almost 100% of the DDX4-labeled oocytes (Videos 1 and 2), following insights from the literature [5, 6], we concluded that the large difference was introduced when the sparse totals were extrapolated. The extrapolation factor, which is based solely on the percentage of slices counted, assumes consistency and ignores variations in follicle size and spatial distribution across the ovary. To visualize the distribution of follicles through the ovary, we graphed the number of StarDist-OoCount-segmented oocytes identified on each Z-slice of our 3D images (Figure S4B). These graphs display distinct peaks and valleys in oocyte counts per Z-plane, showing that follicle distribution is not linear and varies inconsistently across the tissue. Thus, depending on where in the ovary manually counted sections are, extrapolation can lead to mis-estimation in the final follicle count.
Creating a custom StarDist model
Because our model of StarDist was trained on images produced by our lab, we understand that our pipeline may not be versatile enough to segment oocytes from images with different features from our oocyte images. If the images generated in a different lab are incompatible, or do not yield satisfactory results with our versions of StarDist-OoCount, the following steps can be used to customize StarDist-OoCount. This process will require the user to create a new training dataset and retrain our StarDist model. This section uses tools explained in previous sections, so if needed, reference previous sections for additional information.
9.1.1 To train StarDist to segment oocytes from images unlike those produced in our lab, we recommend creating a new training dataset to retrain our StarDist-OoCount model. Create a folder to store the new training dataset. Within it, make two subfolders, one called “Images” and the other called “Masks.”
9.1.2 Begin by opening images as a .tif file in Napari. Click Plugins > Napari-StarDist. Run our model of StarDist following instructions from 7.2, remembering to use the model appropriate for the stage or image scale of ovaries being examined (adult or perinatal).
9.1.3 Once StarDist has run and segmented the oocytes, save the labels layer in “Masks” and the image layer in “Images.” Assuming that our model of StarDist is insufficiently or inaccurately segmenting oocytes in this image, the labels produced by StarDist will need to be corrected (see Video 6, https://napari.org/stable/howtos/layers/labels.html). This can be done using any type of pen tablet or a computer mouse. To remove labels, use the eyedropper tool to select a label that needs to be removed. Once selected, erase the label with the eraser tool, making sure it has been erased from all Z-stacks. To edit pre-existing labels, use the eyedropper tool to select a label that needs to be edited. Once selected, change the size/shape/depth of the label using the paintbrush tool. To add a new label, press “m” on the keyboard, and paint over the missing oocyte, making sure to paint in all Z slices where the oocyte is present. Repeat this for several images or regions of interest (ROIs). Note: StarDist does not support sparse annotations, so it is essential to make sure that all oocytes in the image or ROI are labeled. Save the corrected labels layer in the “Masks” folder, making sure to name it exactly as its corresponding file in “Images.” The resulting image-mask pairs will constitute your training dataset. Make sure to create a copy of the directory for the StarDist-OoCount model (_Adult or _Perinatal) that you wish to retrain in the directory that contains “Images” and “Masks” folders. Note: For optimal training and accuracy, we recommend that your newly produced training data be scaled to match the training data we originally used to create the StarDist-OoCount models. For this, we provide a Python script (resample_tiffs.py) that automatically resamples x and y dimensions for all images and masks (.tif files) present within a specific directory. To run this script, copy the .py file into the directory where your images are located, and open a terminal from there. Run the script by typing “python resampleTiff.py'' and press enter. The script will prompt you to set a rescaling factor. Our adult model expects x and y values of 1.2 μm, and the perinatal model expects x and y dimensions of 0.603 μm. Divide these values by your x and y values to determine the scaling factor to use. Resized images can now be used as StarDist training data.
9.2.1 To retrain our StarDist model, we recommend using DL4MicEverywhere [22]. This platform offers easy-to-use Jupyter notebooks that utilize CNNs to retrain StarDist. First, download Docker Desktop [40] (https://www.docker.com/products/docker-desktop/). Docker is a tool that allows the deployment of applications and all their dependencies as a single unit of software, referred to as a “container.” Open DockerDesktop and create an account. Now that Docker is installed, download the ZIP file of the DL4MicEverywhere Repository from Github [22] (https://github.com/HenriquesLab/DL4MicEverywhere/blob/main/docs/USER_GUIDE.md).
9.2.2 Open Docker Desktop. Within the downloaded DL4MicEverywhere file, double-click the launcher with the appropriate operating system (Windows, MacOS, Linux). A window will open with options for notebooks to run (Figure 10A). Select DL4Mic notebooks and select the notebook for StarDist 3D. Enter the path for the folder containing the training dataset in “data.” Enter the path for the directory where you wish to store the newly trained model in “results.” Select Allow GPU and click Run. From here, the required packages will install and the StarDist 3D Jupyter notebook will open in a browser.
Figure 10.
Retraining StarDist in DL4MicEverywhere. Screenshots from setting up the DL4MicEverywhere notebook to retrain StarDist. (A) Once DL4MicEverywhere has been launched, a window will open with options for notebooks to run. Settings should look like those in this (B). Within the Jupyter notebook, the grid will need to be changed to “grid = (1,4,4).” (C) The “Play” button can be found at the top of the notebook (highlighted here in the box). (D) When setting up the training, the settings of Section 3.1 of the Jupyter notebook should look similar to the settings above.
9.2.3 When prompted, select a Python kernel. While the code in the Jupyter notebook may be intimidating, there is only one line of code that must be modified. Use Ctrl/cmd + F to search for the word “grid.” Find the line of code where the grid is defined. Change “grid = grid” to “grid = (1,4,4)” (Figure 10B). This modification extends the field of view of the neural network and allows segmentation of larger objects, such as large growing oocytes. Click play through the code chunks starting at 1.1 until Section 3.1 of the StarDist 3D Jupyter notebook (Figure 10C, outlined in a magenta box).
9.2.4 At Section 3.1 of the StarDist 3D Jupyter notebook, in “training source,” enter the path for your training images; in “training target,” enter the path for your training masks (as seen in Figure 10D). The paths can be found by right-clicking the directories in the file browser in the left hand of the Jupyter notebook window. Make sure to add the prefix /home/ to the path. These paths should typically look like: /home/data/Images; /home/data/Masks; /home/results/[name for your retrained model]. For “number of epochs,” enter 200 (Figure 10D). The rest of the settings should be left as default. Click load and run. This will display an example image-mask pair from the training dataset. At Section 3.2 of the notebook, don’t enable data augmentation. Click load and run. At Section 3.3 of the StarDist 3D Jupyter notebook, select “Use pretrained model” and use the dropdown bar to select Model from the file. Copy the path to the OoCount-StarDist model you wish to retrain. Click “load and run.” Press play through both code chunks in Section 4 of the notebook. This will begin the training.
9.2.5 To evaluate the newly trained model, play the code chunks in Section 5. This can also be achieved by using the new model in StarDist-Napari on an image that was not a part of the training dataset.
Note: If the IoU is lower than 0.6, we suggest adding more training data or adjusting parameters and retraining the model. However, the user should use their best judgment to determine if they need to retrain. The IoU is a useful metric, but, because it is a quantification of overlap between the ground truth and prediction, it does not tell the user if the number of labeled objects is the same. The ground truth and prediction do not need to overlap perfectly to get the total number of objects (oocytes).
Troubleshooting
Choosing a classifier plugin
While we suggest using APOC to classify oocytes into growth stages, we understand that it may not be ideal because it must be retrained and corrected for each batch of images. Training APOC is quick because it utilizes sparse annotation, which is a strength of this classifier. We also recommend using an activation marker, such as NR5A2, and to not rely only on the size of the oocyte to determine activation, as certain mutations or strain differences may affect the size of the oocyte independently from the growth stage and yield suboptimal classification accuracy. If APOC does not yield satisfactory results or is becoming too cumbersome to train, we suggest trying another classifier Napari plugin called Svetlana [41] (https://pypi.org/project/napari-svetlana/). Svetlana leverages CNNs to create a reusable trained model for classification, meaning the user only trains it once and the trained model can be used on new batches of images. Svetlana has a steeper learning curve, but some users may find it preferable for their workflow. For more information on Svetlana, we suggest reading the user guide (https://www.napari-hub.org/plugins/napari-svetlana). We also anticipate new classifiers will continue to be developed and made available as Napari plugins. The Napari hub (https://www.Napari-hub.org/) catalogs all available Napari plugins and is the ideal place to search for new plugin releases and plugin updates.
Optimizing DL4MicEverywhere
If retraining our StarDist model is necessary, it may require optimization beyond what is outlined in the section above. Some considerations when retraining StarDist include deciding how many epochs to run and the type of computing power available. If a training dataset is a set of flashcards that the neural network will learn from, the number of epochs reflects the number of times the neural network reviews the flashcards or the training dataset. It may be intuitive to believe that more epochs would be better; however, overtraining the model can lead to overfitting and make it less effective. We suggest using somewhere between 100 and 200 epochs. Note: Increasing the number of epochs will also make the training longer and require more computational resources. If computational resources are a limitation, we recommend looking into computer clusters available through your institution or online computer clusters, such as Google Colab (https://colab.google/).
Resources for troubleshooting
Wherever possible, we have included the links to troubleshooting resources for using OoCount. All the programs included in OoCount have excellent documentation and tutorials, which have allowed us to learn these programs and incorporate them into OoCount. In addition to these program-specific resources, our lab will have additional resources on our website (www.mckeylab.com) for troubleshooting OoCount, with an option to contact us with questions.
Conclusions
Ovarian follicle counts are a commonly used and insightful readout in ovarian biology research. With recent advances in 3D imaging, it is easier than ever to visualize the entire ovary and all the oocytes within it. However, analysis of these large images has been a major roadblock, as counting oocytes from these images is time consuming and prone to error. By leveraging machine learning tools, we have developed OoCount, an open-source, accessible workflow to quickly and efficiently segment oocytes and classify them based on growth stages in perinatal and adult mouse ovaries. Currently, OoCount successfully segments oocytes from 3D images of perinatal and adult mouse ovaries and yields results similar to previously published studies [4, 42–45]. However, it is important to note that OoCount was developed and run on CD-1 mice and it has been documented that there are differences in oocyte quantity among mouse strains [5]. Compared to traditional methods for follicle counting, OoCount provides users with definitive counts and a more accurate assessment of the ovarian reserve. Traditional methods are sufficient for comparing conditions where there are strong differences between groups/phenotypes, but OoCount may be a more useful readout for capturing subtle differences or changes in the spatial distribution of follicle classes. While OoCount is not the first computational workflow for oocyte segmentation and classification [11, 16, 46], OoCount is advantageous because it utilizes open-source resources and relies on an oocyte activation marker for classification, allowing for efficient, accessible oocyte segmentation and classification. OoCount was optimized for mouse tissue, and we did not test OoCount on ovaries from other animals; however, we expect it to be easily transferable to other species with some retraining.
Here, we detailed an end-to-end pipeline consisting of protocols optimized in our lab and workflows to segment and classify oocytes from 3D images of perinatal and adult mouse ovaries. While we hope that OoCount will become a widely adopted tool, we understand there are limitations. Our OoCount pipeline is only applicable to 3D images, as the native StarDist model we retrained was the 3D model. If users would like to use StarDist to quantify oocytes on 2D images, they will need to generate a 2D training dataset and retrain StarDist. If the images of sections are confocal Z-stacks and thus have x, y, and z dimensions, the 3D StarDist model could work; however, this has not been tested. Follicular atresia is not accounted for in this pipeline. Any atretic follicles are classified along with other follicles or not segmented due to a low DDX4 signal. Atretic follicles that are segmented by StarDist could be classified in APOC if the user has used an antibody to act as a marker for atresia. Additionally, APOC is limited in its ability to automatically distinguish between secondary and early antral follicles in the adult ovary based only on the expression of DDX4 and NR5A2. We highly recommend careful inspection and manual correction of the APOC predictions for optimal count accuracy. For users particularly interested in distinguishing between these stages, we recommend using a stage-specific marker for better classification in APOC. The entire workflow was generated using a PC with a Windows operating system and may require additional troubleshooting if using a different operating system. We have included links to resources for troubleshooting the different software packages within this workflow (Table S3). As of now, our classification uses APOC, which is the most user-friendly classifier we encountered, but APOC may require the user to retrain it for each set of images. In the future, we hope to develop our own classifier, specific to classifying oocytes in 3D images of mouse ovaries. In addition, we plan to create a plugin or software containing the entire pipeline. We hope this will increase the ease of use of OoCount and provide the field with a much-needed standardized tool for counting oocytes in 3D images of mouse ovaries.
Supplementary Material
Acknowledgment
The authors would like to thank all members of the Capel Lab, McKey Lab, and Roberson Lab for helpful discussions and feedback during the development of this project. The authors would also like to thank Victor A. Ruthig and Elle C. Roberson for feedback on the initial drafts of the manuscript. Special thanks to Leandro Lovisolo for essential training and guidance on computational aspects of this study and to Wendy Zhang for testing the protocol. We would also like to acknowledge Sofia Batchvarova, who patiently annotated an entire 3D mouse ovary in the first iteration of this project.
Conflict of interest: The authors have declared that no conflict of interest exists.
Contributor Information
Lillian Folts, Section of Developmental Biology, Department of Pediatrics, University of Colorado Anschutz Medical Campus, Aurora, CO, USA.
Anthony S Martinez, Section of Developmental Biology, Department of Pediatrics, University of Colorado Anschutz Medical Campus, Aurora, CO, USA.
Jaelyn A Williams, Section of Developmental Biology, Department of Pediatrics, University of Colorado Anschutz Medical Campus, Aurora, CO, USA.
Corey Bunce, Konrad Lorenz Institute for Evolution and Cognition Research, Klosterneuburg, Austria.
Blanche Capel, Department of Cell Biology, Duke University Medical Center, Durham, NC, USA.
Jennifer McKey, Section of Developmental Biology, Department of Pediatrics, University of Colorado Anschutz Medical Campus, Aurora, CO, USA.
Author contributions
JM and BC conceptualized the project. LF, CB, and JM designed and optimized the computational pipeline. LF, ASM, JAW, and JM performed optimization of the bench protocols and data collection. LF produced the initial draft of the manuscript and figures. BC, CB, ASM, JAW, and JM edited the manuscript. JM provided funding for the project.
Data availability
All materials and data presented in the current method manuscript are available as supplementary files and/or on our website at www.mckeylab.com. These materials have also been deposited on Dryad (https://doi.org/10.5061/dryad.nk98sf81r) [39].
References
- 1. McGee EA, Hsueh AJ. Initial and cyclic recruitment of ovarian follicles. Endocr Rev 2000; 21:200–214. [DOI] [PubMed] [Google Scholar]
- 2. John GB, Gallardo TD, Shirley LJ, Castrillon DH. Foxo3 is a PI3K-dependent molecular switch controlling the initiation of oocyte growth. Dev Biol 2008; 321:197–204. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 3. Chen Y, Yang W, Shi X, Zhang C, Song G, Huang D. The factors and pathways regulating the activation of mammalian primordial follicles in vivo. Front Cell Dev Biol 2020; 8:575706. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 4. Findlay JK, Hutt KJ, Hickey M, Anderson RA. How is the number of primordial follicles in the ovarian reserve established? Biol Reprod 2015; 93:111. [DOI] [PubMed] [Google Scholar]
- 5. Myers M, Britt KL, Wreford NGM, Ebling FJP, Kerr JB. Methods for quantifying follicular numbers within the mouse ovary. Reproduction 2004; 127:569–580. [DOI] [PubMed] [Google Scholar]
- 6. Tilly JL. Ovarian follicle counts – not as simple as 1, 2, 3. Reprod Biol Endocrinol 2003; 1:11. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 7. McKey J, Anbarci DN, Bunce C, Ontiveros AE, Behringer RR, Capel B. Integration of mouse ovary morphogenesis with developmental dynamics of the oviduct, ovarian ligaments, and rete ovarii. elife 2022; 11:e81088. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 8. Combes AN, Lesieur E, Harley VR, Sinclair AH, Little MH, Wilhelm D, Koopman P. Three-dimensional visualization of testis cord morphogenesis, a novel tubulogenic mechanism in development. Dev Dyn 2009; 238:1033–1041. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 9. Malki S, Tharp ME, Bortvin A. A whole-mount approach for accurate quantitative and spatial assessment of Fetal oocyte dynamics in Mice1. Biol Reprod 2015; 93:1–9. [DOI] [PubMed] [Google Scholar]
- 10. Soygur B, Laird DJ. Ovary development: insights from a three-dimensional imaging revolution. Front Cell Dev Biol 2021; 9:9. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 11. Soygur B, Foecke MH, Gaylord EA, Fries A, Li J, Arora R, Laird DJ. A Roadmap for Three-Dimensional Analysis of the Intact Mouse Ovary. In: Buszczak M (ed.), Germline Stem Cells: Methods and Protocols. New York, NY: Springer US: Springer US; 2023: 203–219. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 12. Boateng R, Boechat N, Henrich PP, Bolcun-Filas E. Whole ovary immunofluorescence, clearing, and multiphoton microscopy for quantitative 3D analysis of the developing ovarian Reserve in Mouse. J Vis Exp 2021; (175):e62972. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 13. Faire M, Skillern A, Arora R, Nguyen DH, Wang J, Chamberlain C, German MS, Fung JC, Laird DJ. Follicle dynamics and global organization in the intact mouse ovary. Dev Biol 2015; 403:69–79. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 14. Feng Y, Cui P, Lu X, Hsueh B, Möller Billig F, Zarnescu Yanez L, Tomer R, Boerboom D, Carmeliet P, Deisseroth K, Hsueh AJW. CLARITY reveals dynamics of ovarian follicular architecture and vasculature in three-dimensions. Sci Rep 2017; 7:44810. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 15. McKey J, Cameron LA, Lewis D, Batchvarov IS, Capel B. Combined iDISCO and CUBIC tissue clearing and lightsheet microscopy for in toto analysis of the adult mouse ovary. Biol Reprod 2020; 102:1080–1089. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 16. Lesage M, Thomas M, Pécot T, Ly T-K, Hinfray N, Beaudouin R, Neumann M, Lovell-Badge R, Bugeon J, Thermes V. An end-to-end pipeline based on open source deep learning tools for reliable analysis of complex 3D images of ovaries. Development 2023; 150:dev201185. [DOI] [PubMed] [Google Scholar]
- 17. Folts L, Martinez AS, McKey J. Tissue clearing and imaging approaches for in toto analysis of the reproductive system. Biol Reprod 2023; 110:1041–1054. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 18. Cutrale F, Fraser SE, Trinh LA. Imaging, visualization, and computation in developmental biology. Annu Rev Biomed Data Sci 2019; 2:223–251. [Google Scholar]
- 19. Hallou A, Yevick HG, Dumitrascu B, Uhlmann V. Deep learning for bioimage analysis in developmental biology. Development 2021; 148:dev199616. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 20. Moen E, Bannon D, Kudo T, Graf W, Covert M, Van Valen D. Deep learning for cellular image analysis. Nat Methods 2019; 16:1233–1246. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 21. Morgado L, Gómez-de-Mariscal E, Heil HS, Henriques R. The rise of data-driven microscopy powered by machine learning. J Microsc 2024; 295:85–92. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 22. Hidalgo-Cenalmor I, Pylvänäinen JW, Ferreira MG, Russell CT, Saguy A, Arganda-Carreras I, Shechtman Y, AI4Life Horizon Europe Program Consortium, Jacquemet G, Henriques R, Gómez-de-Mariscal E. DL4MicEverywhere: deep learning for microscopy made flexible, shareable and reproducible. Nat Methods 2024; 21:925–927. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 23. von Chamier L, Laine RF, Jukkala J, Spahn C, Krentzel D, Nehme E, Lerche M, Hernández-Pérez S, Mattila PK, Karinou E, Holden S, Solak AC, et al. Democratising deep learning for microscopy with ZeroCostDL4Mic. Nat Commun 2021; 12:2276. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 24. Stringer C, Wang T, Michaelos M, Pachitariu M. Cellpose: a generalist algorithm for cellular segmentation. Nat Methods 2021; 18:100–106. [DOI] [PubMed] [Google Scholar]
- 25. Schmidt U, Weigert M, Broaddus C, Myers G. Cell Detection with Star-Convex Polygons. In: Frangi AF, Schnabel JA, Davatzikos C, Alberola-López C, Fichtinger G (eds.), Medical Image Computing and Computer Assisted Intervention – MICCAI 2018. Cham: Springer International Publishing; 2018: 265–273. [Google Scholar]
- 26. Haase R, Fazeli E, Legland D, Doube M, Culley S, Belevich I, Jokitalo E, Schorb M, Klemm A, Tischer C. A Hitchhiker’s guide through the bio-image analysis software universe. FEBS Lett 2022; 596:2472–2485. [DOI] [PubMed] [Google Scholar]
- 27. Weigert M, Schmidt U, Haase R, Sugawara K, Myers G. Star-convex Polyhedra for 3D object detection and segmentation in microscopy. IEEE Winter Conference on Applications of Computer Vision (WACV) 2020; 2020:3655–3662. [Google Scholar]
- 28. Sofroniew N, Lambert T, Evans K, Nunez-Iglesias J, Bokota G, Bussonnier M, Peña-Castellanos G, Winston P, Yamauchi K, Pop DD, Alisterburt P, et al. Napari/napari. Zenodo 2022; 0.4.14.
- 29. Haase R, Pop DD, Žigutytė L. Haesleinhuepf/napari-accelerated-pixel-and-object-classification: 0.8.2. Zenodo 2022.
- 30. Morgan S, Campbell L, Allison V, Murray A, Spears N. Culture and Co-culture of mouse ovaries and ovarian follicles. J Vis Exp 2015; 97;52458. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 31. Converse A, Zaniker EJ, Amargant F, Duncan FE. Recapitulating folliculogenesis and oogenesis outside the body: encapsulated in vitro follicle growth†. Biol Reprod 2023; 108:5–22. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 32. Meinsohn M-C, Saatcioglu HD, Wei L, Li Y, Horn H, Chauvin M, Kano M, Nguyen NMP, Nagykery N, Kashiwagi A, Samore WR, Wang D, et al. Single-cell sequencing reveals suppressive transcriptional programs regulated by MIS/AMH in neonatal ovaries. Proc Natl Acad Sci USA 2021; 118:e2100920118. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 33. Meinsohn M-C, Morin F, Bertolin K, Duggavathi R, Schoonjans K, Murphy BD. The orphan nuclear receptor liver homolog Receptor-1 (Nr5a2) regulates ovarian granulosa cell proliferation. J Endocr Soc 2018; 2:24–41. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 34. Zhao H, Li Z, Cooney AJ, Lan Z-J. Orphan nuclear receptor function in the ovary. Front Biosci 2007; 12:3398–3405. [DOI] [PubMed] [Google Scholar]
- 35. McKey J, Bunce C, Batchvarov IS, Ornitz DM, Capel B. Neural crest-derived neurons invade the ovary but not the testis during mouse gonad development. Proc Natl Acad Sci USA 2019; 116:5570–5575. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 36. Schindelin J, Arganda-Carreras I, Frise E, Kaynig V, Longair M, Pietzsch T, Preibisch S, Rueden C, Saalfeld S, Schmid B, Tinevez J-Y, White DJ, et al. Fiji: an open-source platform for biological-image analysis. Nat Methods 2012; 9:676–682. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 37. Sofroniew N, Lambert T, Evans K, Nunez-Iglesias J, Bokota G, Winston P, Peña-Castellanos G, Yamauchi K, Bussonnier M, Doncila Pop D, Can Solak A, Liu Z, et al. Napari: a multi-dimensional image viewer for python. Zenodo 2022.
- 38. Royer LA. Omega – harnessing the power of large language models for bioimage analysis. Nat Methods 2024; 21:1371–1373. [DOI] [PubMed] [Google Scholar]
- 39. Folts L, Martinez A, Bunce C, Capel B, McKey J. Data from: OoCount: a machine-learning based approach to mouse ovarian follicle counting and classification [dataset]. Dryad 2024. 10.5061/dryad.nk98sf81r. [DOI] [PMC free article] [PubMed]
- 40. Merkel D. Docker: lightweight Linux containers for consistent development and deployment. Linux J 2014; 2014:2. [Google Scholar]
- 41. Cazorla C, Morin R, Weiss P. Svetlana a supervised segmentation classifier for Napari. Sci Rep 2024; 14:11604. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 42. Nguyen DH, Soygur B, Peng S-P, Malki S, Hu G, Laird DJ. Apoptosis in the foetal testis eliminates developmentally defective germ cell clones. Nat Cell Biol 2020; 22:1423–1435. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 43. Zhihan T, Xinyi M, Qingying L, Rufei G, Yan Z, Xuemei C, Yanqing G, Yingxiong W, Junlin H. Autophagy participates in cyst breakdown and primordial folliculogenesis by reducing reactive oxygen species levels in perinatal mouse ovaries. J Cell Physiol 2019; 234:6125–6135. [DOI] [PubMed] [Google Scholar]
- 44. Song Z-H, Yu H-Y, Wang P, Mao G-K, Liu W-X, Li M-N, Wang H-N, Shang Y-L, Liu C, Xu Z-L, Sun Q-Y, Li W. Germ cell-specific Atg7 knockout results in primary ovarian insufficiency in female mice. Cell Death Dis 2015; 6:e1589. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 45. Park CJ, Oh J-E, Feng J, Cho YM, Qiao H, Ko C. Lifetime changes of the oocyte pool: contributing factors with a focus on ovulatory inflammation. Clin Exp Reprod Med 2022; 49:16–25. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 46. Blevins GM, Flanagan CL, Kallakuri SS, Meyer OM, Nimmagadda L, Hatch JD, Shea SA, Padmanabhan V, Shikanov A. Quantification of follicles in human ovarian tissue using image processing software and trained artificial intelligence. Biol Reprod 2024; 110:1086–1099. [DOI] [PMC free article] [PubMed] [Google Scholar]
Associated Data
This section collects any data citations, data availability statements, or supplementary materials included in this article.
Data Citations
- Folts L, Martinez A, Bunce C, Capel B, McKey J. Data from: OoCount: a machine-learning based approach to mouse ovarian follicle counting and classification [dataset]. Dryad 2024. 10.5061/dryad.nk98sf81r. [DOI] [PMC free article] [PubMed]
Supplementary Materials
Data Availability Statement
All materials and data presented in the current method manuscript are available as supplementary files and/or on our website at www.mckeylab.com. These materials have also been deposited on Dryad (https://doi.org/10.5061/dryad.nk98sf81r) [39].











