This Python script processes the output CSV files from QuPath telomere segmentation. It calculates several new features related to telomere intensity per nucleus and saves the results into a specified output directory.
- Go to the GitHub repository
processTelomereSegmentation
- Click on
<> Code
>Download ZIP
- The downloaded repo will be found in the Downloads directory of your computer.
-
Open a terminal or Anaconda Prompt.
TIP: In the Microscopy Unit, we usually work with Miniforge. There is already a preconfigured environment to run this code. Most workstations have a shortcut to open the Miniforge Prompt directly. Make sure that the window title says something like:
-
Activate the
cellpose
environment (or the environment where your required packages are installed).
If you used Anaconda to install Cellpose, you can activate it by typing:
conda activate cellpose
Note: If you installed the dependencies in a different environment, make sure to activate the correct one.
- Navigate to the location where you downloaded the repository and inside the src folder in the repository:
cd path/to/telomere_quantification/src
- Run the main Python script:
python main.py
-
A GUI will pop up asking you to select:
-
Input directory: The folder where your QuPath telomere segmentation CSV files are stored.
CAUTION: The input directory must contain only the .csv files you want to process.Do not include any other files in that folder, as the script assumes all files ending in .csv are valid inputs and will attempt to process them.
-
Output directory: The folder where the processed CSV files with the new calculated features will be saved.
-
-
After selecting the directories, the script will start processing each file. When the processing finishes, you will see a message in the terminal for each file like:
Processed file saved at: [path_to_file]_processed.csv
This confirms that the file was successfully processed and saved. Each processed file keeps its original name with the suffix _processed added.
-
Once the script finishes, you will find the processed CSV files in your selected output directory.
Each output CSV will include the following new calculated columns:
Column name | Description |
---|---|
Integrated density |
Sum intensity of each spot = mean intensity × area |
Integrated density - mean per cell |
Mean per nucleus of sum intensity |
Integrated density*number of foci - mean per cell |
Mean per nucleus of sum intensity × number of foci |
Mean intensity - mean per cell |
Mean per nucleus of mean intensity |
Max intensity - mean per cell |
Mean per nucleus of max intensity |
Max intensity*number of foci - mean per cell |
Mean per nucleus of max intensity × number of foci |
- You can now use the processed data for further analysis!
This script is located inside the src/qupath_analysis_script
folder in the repository. It will segment the nuclei of the cells with Cellpose deep learning models, using Channel 1(DAPI). After this step, it will segment, with a threshold-based algorithm, the spots (telomeres) on Channel 3. Then, it will calculate Max and Min intensities for each spot. And finally, it will export all measurements as a tab-separated csv file per image. If you want a per-cell summary of the spot measurements, you will have to run the python script mentioned above, to process all the csv files that QuPath generates. Before running this script, please create a folder named "output" at the same level as the QuPath project files.