Skip to main content

JIMG_int – Python library for marker intensity and distribution analysis

Python version License Docs

drawing drawing


Author: Jakub Kubiś

Institute of Bioorganic Chemistry
Polish Academy of Sciences

Description

JIMG_int is a Python library designed to quantify and analyze marker intensity and spatial distribution in images. It is particularly useful for biological imaging, immunofluorescence, or any field requiring analysis of labeled markers in microscopy or medical images.

The library support the JIMG image processing tool, specifically tailored for analyzing high-resolution confocal microscope images Opera-Phoenix and other technologies.

It provides algorithms for measuring the intensity of specific protein markers using customizable image masks on high-resolution microscope images. These measurements are normalized using a background mask for consistent data comparison. The collected intensity data can be statistically analyzed to detect differences in marker localization, occurrence, and intensity.



📚 Table of Contents



1. Installation

In command line write:

pip install jimg-int

2. Documenation

Documentation for classes and functions is available here 👉 Documentation 📄

3. Example pipelines

If you want to run the examples, you must download the test data. To do this, use:

from jimg_ncd.nuclei import test_data

test_data()

3.1 Marker intensity features extraction

3.1.1 Adjusting parameters and image loading
from jimg_int.intensity import FeatureIntensity

# Select intenity are data for 1st Image - healthy

# initiate class
fi = FeatureIntensity()

# check current metadata
fi.current_metadata

# if required, change parameters
fi.set_projection(projection="avg")

fi.set_correction_factorn(factor=0.2)

# fi.set_scale(scale = 0.5)
# fi.set_selection_list(rm_list = [2,5,6,7])
# OR
# load JIMG project where scale and rm_lis is set in project metadata
# fi.load_JIMG_project_(path = '')
# for more information go to: https://github.com/jkubis96/JIMG
# rm_list and scale can be omitted

# load image
fi.load_image_3D(path="test_data/intensity/ctrl/image.tiff")

# or 1D image after projection, be sure that image was not adjusted, for analysis should be use !RAW! image
# fi.load_image_(path)

Analysed image projection (after projection with JIMG)

  • input image in this case is raw 3D-image in *.tiff format

drawing


3.1.2 ROI mask loading
fi.load_mask_(path = 'test_data/intensity/ctrl/mask_1.png')

Analysed image region mask

drawing


3.1.3 Normalization mask loading
fi.load_normalization_mask_(path = 'test_data/intensity/ctrl/background_1.png')

Normalization region mask (reversed)

drawing


3.1.4 Extracting intensity values
# strat calculations
fi.run_calculations()


# get results
results = fi.get_results()
3.1.5 Saving intensity data
# save results for further analysis, ensuring each feature 
# is stored in a separate directory (single directory 
# should contain data with the same 'feature_name'),
# this setup allows running fi.concatenate_intensity_data() 
# in the specific directory of each feature
# while preventing errors from incorrect feature concatenation

fi.save_results(path = os.getcwd(), 
             mask_region = 'brain', 
             feature_name = 'Feature1', 
             individual_number = 1, 
             individual_name = 'CTRL')
3.1.6 Performing analysis pipeline for the subsequent image
  • Apply steps 3.1.1–3.1.5 to the subsequent image to support comparison analysis.
# Select intenity are data for 2st Image - disease

# initiate class
fi = FeatureIntensity()

fi.set_projection(projection="avg")

fi.set_correction_factorn(factor=0.2)

fi.load_image_3D(path="test_data/intensity/dise/image.tiff")

###############################################################################

fi.load_mask_(path="test_data/intensity/dise/mask_1.png")

###############################################################################

fi.load_normalization_mask_(path="test_data/intensity/dise/background_1.png")

###############################################################################

fi.run_calculations()

results = fi.get_results()

fi.save_results(
    path="",
    mask_region="brain",
    feature_name="Feature1",
    individual_number=1,
    individual_name="DISEASE",
)

Analysed image projection (after projection with JIMG)

  • input image in this case is raw 3D-image in *.tiff format

drawing


Normalization region mask (reversed)

drawing


Analysed image region mask

drawing

3.1.7 Combining the experimental data
# concatenate data of experiment 1 & 2
fi.concatenate_intensity_data(directory="", name="example_data")

3.2 Analyzing the intensity and spatial distribution of the marker

3.2.1 Loading experimental data

import pandas as pd
from jimg_int.intensity import IntensityAnalysis

# initiate class
ia = IntensityAnalysis()

input_data = pd.read_csv("example_data_Feature1_brain.csv")

# check columns
input_data.head()

3.2.2 Quantitative analysis of marker intensity and spatial distribution

data = ia.df_to_percentiles(
    data=input_data,
    group_col="individual_name",
    values_col="norm_intensity",
    replication_col = 'individual_number',
    sep_perc=1,
)

stats = ia.get_stats(data, tested_value = 'avg')

3.2.3 Visualizing the data using a histogram distribution

results = ia.hist_compare_plot(
    data=stats, queue=["CTRL", "DISEASE"], p_adj=True, txt_size=20
)

Results of intensity comparison analysis (region under the mask)

drawing


results.savefig('example_results.svg', format = 'svg', dpi = 300, bbox_inches = 'tight')


Have fun JBS

Metadata

Release files for jimg-int 0.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jimg-int 0.1.5
File Size Uploaded
jimg_int-0.1.5.tar.gz 34.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for jimg-int 0.1.5
File Interpreter ABI Platform
jimg_int-0.1.5-py3-none-any.whl Python 3 none any Details

Total release size: 70.2 kB

Release files / jimg_int-0.1.5.tar.gz

Download URL jimg_int-0.1.5.tar.gz
Size 34.5 kB
Tags Source
SHA-256 checksum
How to use checksums
636ae62872799476ddd70d8fcdf419c260f9ec38a50f9166f86929c217bbbd29
BLAKE2b-256 checksum
How to use checksums
64a508070958f08a1684467c20627ea6ee2715935d8c7143c2ab827d89cf1dfb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

Release files / jimg_int-0.1.5-py3-none-any.whl

Download URL jimg_int-0.1.5-py3-none-any.whl
Size 35.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d57a1d80f9c99f546af70c0c23df098500ae0b83449862691aa2461ff3b792a4
BLAKE2b-256 checksum
How to use checksums
732ec77c14db21a249ae52eeb4cb89d443559b890f87e1fd0a08eb9cecd8b4bc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

Release history Release notifications | RSS feed

This release

0.1.5 This release

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page