TITLE: Quantification of fibrosis extend and airspace availability in lung: a semi-automatic ImageJ/Fiji toolbox (step-by-step protocol)
AUTHORS: Bertrand-David Ségard

[DESCRIPTION]
The evaluation of the structural integrity of mechanically dynamic organs such as lungs is critical for the diagnosis of numerous pathologies and the development of therapies. This task is classically performed by histology experts in a qualitative or semi-quantitative manner. Automatic digital image processing methods appeared in the last decades, and although immensely powerful, tools are highly specialized and lack the versatility required in various experimental designs. Here, a set of scripts for the image processing software ImageJ/Fiji to easily quantify fibrosis extend and alveolar airspace availability in Sirius Red or Masson’s trichrome stained samples is presented. The toolbox consists in thirteen modules: sample detection, particles filtration (automatic and manual), border definition, air ducts identification, air ducts walls definition, parenchyma extraction, MT-staining specific pre-processing, fibrosis detection, fibrosis particles filtration, airspace detection, and visualizations (tissue only or tissue and airspace). While the process is largely automated, critical parameters are accessible to the user for increased adaptability. The modularity of the protocol allows for its adjustment to alternative experimental settings. Fibrosis and airspace can be combined as an evaluation of the structural integrity of the organ. All settings and intermediate states are saved to ensure reproducibility. These new analysis scripts allow for a rapid quantification of fibrosis and airspace in a large variety of experimental settings.

[BEFORE_START]
Files with the “ijm” extension must be copied to the plugins folder of ImageJ/Fiji (e.g., …/Fiji/plugins/Fibrosis).

ImageJ/Fiji manages images directly in the RAM of the computer. The maximum RAM ImageJ/Fiji is allowed to use is set in a dedicated menu (Edit > Options > Memory & Threads…).

Alternatively, ImageJ/Fiji can import large images as "Virtual Stack" to avoid loading all data in the RAM. A dedicated menu is available to use this format (File > Import > TIFF Virtual Stack…). Note that displaying the image will be slower.

The plugin Bio-Formats supports BigTiff (File > Import > Bio-Formats) and can manage extremely large images.

Recommendations on lung sample preparation can be found in:
Hsia CC, Hyde DM, Ochs M, Weibel ER; ATS/ERS Joint Task Force on Quantitative Assessment of Lung Structure. An official research policy statement of the American Thoracic Society/European Respiratory Society: standards for quantitative assessment of lung structure. Am J Respir Crit Care Med. 2010 Feb 15;181(4):394-418. doi: 10.1164/rccm.200809-1522ST. PMID: 20130146; PMCID: PMC5455840.
Slides of different anatomical positions within the lungs should be analyzed to minimize sampling or orientation bias.

[GUIDELINES]
In the following protocol, typographical emphases and brackets have been used for software and in-text references.

They are: (1) software features and tools written in bold, e.g., Wand (tracing) tool; (2) references to steps of the protocol in italics, e.g., step 2; (3) <keyboard buttons> in <angle markers>, e.g., <delete>; and (4) computational workflows linked by angle markers (>), e.g., Plugins > Macros > Edit….

This protocol has been developed for ImageJ/Fiji. Nevertheless, forks can also be used. In this case, some functionalities may be accessed and applied differently.

[STEPS]
SECTION: Sample detection
1. Sample detection

Note: the scale of images must be defined prior to the analysis.
SECTION: Background cleaning
2. Background cleaning

SECTION: Sample detection
1.1. Open the image to be analyzed (File > Open…).
 
SECTION: Sample detection
1.2. Launch the script (Plugins > Fibrosis > Sample detection).
SECTION: Sample detection
1.3. Define the scale of the image (i.e., px / μm). Click the “OK” button.
SECTION: Sample detection
1.5. Save output files in the desired folder (check the "Save" box and click "OK").
SECTION: Sample detection
1.4. Define the lower (close to black: strongly stained tissue) and upper (close to white: lightly stained tissue) thresholds (reset to automatically defined values available). Selected objects are highlighted in yellow on the overlay.
To finish, check the “Confirm settings” box and click the “OK” button.
 
SECTION: Background cleaning
2.2. Open the mask of the sample obtained at step 1.5 (File > Open…).
SECTION: Background cleaning
2.3. Launch the script (Plugins > Fibrosis > Particle filter auto).
SECTION: Background cleaning
2.4. Define the minimal and maximal size cutoffs (reset to default values available). Selected objects are highlighted in orange on the overlay.
To finish, check the “Confirm settings” box and click the “OK” button.
SECTION: Background cleaning
2.5. Save output files in the desired folder (check the "Save" box and click "OK").
SECTION: Background cleaning
2.6. Manual cleaning
SECTION: Background cleaning
2.7. Open the mask of the sample obtained at step 2.5 (File > Open…).
SECTION: Background cleaning
2.8. Launch the script (Plugins > Fibrosis > Particle filter manual).
SECTION: Background cleaning
2.9. Using a selection tool (e.g., Rectangle), select undesirable objects in the background and delete them (<delete>). Click the “OK” button on the dialog window.

Note: it is not necessary to clean particles in air ducts as most will be deleted at the air ducts identification step.
SECTION: Background cleaning
2.10. Selected objects are highlighted in magenta on the overlay.
To finish, check the “Confirm cleaning” box and click the “OK” button.
 
SECTION: Background cleaning
2.11. Save output files in the desired folder (check the "Save" box and click "OK").
SECTION: Border definition
3. Border definition
SECTION: Border definition
3.1. Open the mask of the sample obtained at step 2.11 (File > Open…).
SECTION: Border definition
3.2. Launch the script (Plugins > Fibrosis > Border definition).
SECTION: Border definition
3.3. Using a drawing tool (e.g., Pencil Tool), repair breaks in the border of the sample. Tissues are highlighted in orange and airspace in black on the overlay.
To finish, check the “Confirm correction” box and click the “OK” button.
SECTION: Border definition
3.4. Define the size of the border (reset to default value available). Selected objects are highlighted in green on the overlay.
To finish, check the "Confirm settings" box and click the “OK” button.
 
SECTION: Border definition
3.5. Save output files in the desired folder (check the "Save" box and click "OK").
SECTION: Air ducts and air ducts walls definition
4. Air ducts and air ducts walls definition
SECTION: Air ducts and air ducts walls definition
4.2. Open the mask of the sample obtained at step 2.11 (File > Open…).
SECTION: Air ducts and air ducts walls definition
4.3. Launch the script (Plugins > Fibrosis > Air duct identification).
SECTION: Air ducts and air ducts walls definition
4.4. Check the “Add new air duct” box and click the “OK” button to enter the selection mode.
SECTION: Air ducts and air ducts walls definition
4.5. Using a selection tool (e.g., Wand (tracing) tool), select an air duct. It is advised to add air ducts one by one. To validate a selection, click the “OK” button on the dialog window. Selected objects are highlighted in cyan on the overlay.

Note: check the “Delete last air duct” box and click the “OK” button to remove the last air duct from the selection.

To finish, check the "Confirm selection" box and click the “OK” button.
 
SECTION: Air ducts and air ducts walls definition
4.6. Save output files in the desired folder (check the "Save" box and click "OK").
SECTION: Air ducts and air ducts walls definition
4.7. Air ducts walls definition
SECTION: Air ducts and air ducts walls definition
4.8. Launch the script (Plugins > Fibrosis > Air ducts walls definition).
SECTION: Air ducts and air ducts walls definition
4.10. Define the size of air ducts walls (reset to default value available). Selected objects are highlighted in green on the overlay.
To finish, check the "Confirm settings" box and click the “OK” button.
 
SECTION: Air ducts and air ducts walls definition
4.11. Save output files in the desired folder (check the "Save" box and click "OK").
SECTION: Parenchyma extraction
5. Parenchyma extraction
SECTION: Parenchyma extraction
5.1. Launch the script (Plugins > Fibrosis > Parenchyma extraction).
SECTION: Parenchyma extraction
5.2. Open the required files (automatic prompt):
sample image (original)
clean mask (from step 2.11)
sample border ROI set (from step 3.5)
air ducts walls ROI set (from step 4.11)
SECTION: Parenchyma extraction
5.3. Define the scale of the image (i.e., px / μm). Click the “OK” button.
 
SECTION: Parenchyma extraction
5.4. Save output files in the desired folder (check the "Save" box and click "OK").
SECTION: [Only for MT-stained samples] Connective tissue extraction
6. Connective tissue extraction

Note: it is recommended to use Fiji as this module has a dependency to the plugin Colour Deconvolution.
SECTION: [Only for MT-stained samples] Connective tissue extraction
6.1. Open the image of the parenchyma obtained at step 5.4 (File > Open…).
SECTION: [Only for MT-stained samples] Connective tissue extraction
6.2. Launch the script (Plugins > Fibrosis > MT pre-processing).
SECTION: [Only for MT-stained samples] Connective tissue extraction
6.3. Save output files in the desired folder (check the "Save" box and click "OK").
SECTION: Fibrosis detection
7. Fibrosis detection

Note: the separation of color channels is different between SR and MT, which leads to different threshold settings.
SECTION: Fibrosis detection
7.1. Open the image of the parenchyma (SR; step 5.4) or of the connective tissue in the parenchyma (MT; step 6.3) (File > Open…).
SECTION: Fibrosis detection
7.2. Launch the script (Plugins > Fibrosis > Fibrosis detection).
SECTION: Fibrosis detection
7.3. Define the scale of the image (i.e., px / μm). Click the “OK” button.
SECTION: Fibrosis detection
7.4. Define the lower (close to black: strongly stained tissue) and upper (close to white: lightly stained tissue) thresholds (reset to automatically defined values available). Selected objects are highlighted in red on the overlay.
To finish, check the “Confirm settings” box and click the “OK” button.
 
SECTION: Fibrosis detection
7.5. Save output files in the desired folder (check the "Save" box and click "OK").
SECTION: Tissue visualization
9. Overlay of tissue segmentation
SECTION: Tissue visualization
9.1. Launch the script (Plugins > Fibrosis > Visualization tissue).
SECTION: Tissue visualization
9.2. Open the required files (automatic prompt):
sample image (original)
parenchyma ROI set (from step 5.4)
sample border ROI set (from step 3.5)
air ducts walls ROI set (from step 4.11)
air ducts ROI set (from step 4.6)
fibrosis ROI set (from step 8.5)
 
SECTION: Tissue visualization
9.3. Save output files in the desired folder (check the "Save" box and click "OK").
SECTION: Airspace quantification
10. Airspace quantification
SECTION: Airspace quantification
10.2. Open the required files (automatic prompt):
parenchyma image (from step 5.4)
sample border ROI set (from step 3.5)
air ducts walls ROI set (from step 4.11)
SECTION: Airspace quantification
10.1. Launch the script (Plugins > Fibrosis > Airspace detection).
SECTION: Airspace quantification
10.3. Define the minimal and maximal size and circularity cutoffs (reset to default values available). Selected objects are highlighted in blue on the overlay.
To finish, check the “Confirm settings” box and click the “OK” button.
 
SECTION: Airspace quantification
10.4. Save output files in the desired folder (check the "Save" box and click "OK").
SECTION: Tissue and airspace visualization
11. Overlay of tissue and airspace segmentation
SECTION: Background cleaning
2.1. Automatic filtering
SECTION: Air ducts and air ducts walls definition
4.1. Air ducts identification

Note: as it is not easy to identify air ducts on a binary mask, it is advised to refer to the original image.
SECTION: Air ducts and air ducts walls definition
4.9. Open the required files (automatic prompt):
clean mask (from step 2.11)
air ducts ROI set (from step 4.6)
SECTION: Fibrosis cleaning
8. Fibrosis cleaning

Note: SR and MT stain different structures, which leads to different filter settings.
SECTION: Fibrosis cleaning
8.1. Automatic filtering
SECTION: Fibrosis cleaning
8.2. Open the mask of the fibrotic tissue obtained at step 7.5 (File > Open…).
SECTION: Fibrosis cleaning
8.3. Launch the script (Plugins > Fibrosis > Fibrosis filter auto).
SECTION: Fibrosis cleaning
8.4. Define the minimal and maximal size cutoffs (reset to default values available). Selected objects are highlighted in magenta on the overlay.
To finish, check the “Confirm settings” box and click the “OK” button.
 
SECTION: Fibrosis cleaning
8.5. Save output files in the desired folder (check the "Save" box and click "OK").
SECTION: Tissue and airspace visualization
11.1. Launch the script (Plugins > Fibrosis > Visualization tissue airspace).
SECTION: Tissue and airspace visualization
11.2. Open the required files (automatic prompt):
tissue visualization image (from step 9.3)
airspace ROI set (from step 10.4)
 
SECTION: Tissue and airspace visualization
11.3. Save output files in the desired folder (check the "Save" box and click "OK").
SECTION: Results
12. Compilation of results
Files and data:
Parenchyma area: (from step 5.4) Results.csv -> Area(Parenchyma)
Fibrosis area: (from step 8.5) Summary.csv -> Total Area
Airspace area: (from step 10.4) Summary.csv -> Total Area
Calculations:
Ratio fibrosis/parenchyma = Fibrosis area / Parenchyma area
Ratio airspace/sample = Airspace area / (Parenchyma area + Airspace area)