Explorer l’Archive BioImage#
Dans ce notebook, nous utilisons le projet bia-explorer pour explorer le jeu de données S-BIAD634 dans la Bio-image Archive. Nous allons télécharger quelques images et les stocker dans un répertoire local.
from bia_explorer import io, biostudies
from skimage.io import imread, imsave
from IPython.display import display, Markdown
import stackview
Accéder aux métadonnées#
Tout d’abord, nous accédons aux métadonnées des jeux de données. Ici, nous pouvons par exemple voir à quoi peuvent servir les données et sous quelle licence elles peuvent être utilisées.
accession = 'S-BIAD634'
submission = biostudies.load_submission(accession)
for a in submission.section.attributes:
name = a.name
short_value = str(a.value)
print(f"{name} : {short_value}")
Title : An annotated fluorescence image dataset for training nuclear segmentation methods
Description : This dataset contains annotated fluorescent nuclear images of normal or cancer cells from different tissue origins and sample preparation types, and can be used to train machine-learning based nuclear image segmentation algorithms. It consists of 79 expert-annotated fluorescence images of immuno and DAPI stained samples containing 7813 nuclei in total. In addition, the dataset is heterogenous in aspects such as type of preparation, imaging modality, magnification, signal-to-noise ratio and other technical aspects. Relevant parameters, e.g. diagnosis, magnification, signal-to-noise ratio and modality with respect to the type of preparation are provided in the file list. The images are derived from one Schwann cell stroma-rich tissue (from a ganglioneuroblastoma) cryosection (10 images/2773 nuclei), seven neuroblastoma (NB) patients (19 images/931 nuclei), one Wilms patient (1 image/102 nuclei), two NB cell lines (CLB-Ma, STA-NB10) (8 images/1785 nuclei) and a human keratinocyte cell line (HaCaT) (41 images/2222 nuclei).
Keywords : AI
Keywords : segmentation
Keywords : nucleus
Keywords : fluorescence
License : CC0
Funding statement : This work was facilitated by an EraSME grant (project TisQuant) under the grant no. 844198 and by a COIN grant (project VISIOMICS) under the grant no. 861750, both grants kindly provided by the Austrian Research Promotion Agency (FFG), and the St. Anna Kinderkrebsforschung. Partial funding was further provided by BMK, BMDW, and the Province of Upper Austria in the frame of the COMET Programme managed by FFG.
Nous pouvons également voir combien d’images se trouvent dans le jeu de données.
study = io.load_bia_study(accession)
len(study.images)
388
Visualiser les images#
Une seule image peut être chargée et affichée comme ceci (Voir aussi).
image = study.images[0]
image
BIAImage(uri='https://www.ebi.ac.uk/biostudies/files/S-BIAD634/dataset\\groundtruth\\Ganglioneuroblastoma_0.tif', size=2239668, fpath=WindowsPath('dataset/groundtruth/Ganglioneuroblastoma_0.tif'))
uri = image.uri.replace("\\", "/")
image_data = imread(uri)
stackview.insight(image_data)
|
|
|
Pour avoir une idée de la structure des dossiers au sein des jeux de données, nous pouvons imprimer les chemins sur le serveur.
# imprimer les noms de fichiers de quelques images
for image in study.images[:5] + study.images[-5:]:
print(str(image.fpath))
dataset\groundtruth\Ganglioneuroblastoma_0.tif
dataset\groundtruth\Ganglioneuroblastoma_1.tif
dataset\groundtruth\Ganglioneuroblastoma_10.tif
dataset\groundtruth\Ganglioneuroblastoma_2.tif
dataset\groundtruth\Ganglioneuroblastoma_3.tif
dataset\rawimages\otherspecimen_5.tif
dataset\rawimages\otherspecimen_6.tif
dataset\rawimages\otherspecimen_7.tif
dataset\rawimages\otherspecimen_8.tif
dataset\rawimages\otherspecimen_9.tif
Télécharger des données#
Avant de télécharger les images sélectionnées, nous devons nous assurer que le dossier où nous voulons stocker les données existe.
import os
def ensure_folder_exists(folder_path):
if not os.path.exists(folder_path):
os.makedirs(folder_path)
base_folder = f"../../data/{accession}"
raw_folder = f"../../data/{accession}/images"
groundtruth_folder = f"../../data/{accession}/groundtruth"
ensure_folder_exists(base_folder)
ensure_folder_exists(raw_folder)
ensure_folder_exists(groundtruth_folder)
Ensuite, nous téléchargeons toutes les images brutes et les annotations de vérité terrain de tous les jeux de données contenant “Ganglioneuroblastoma” dans leur nom. Nous ne téléchargeons les fichiers que s’ils ne sont pas déjà téléchargés.
for image in study.images:
if "Ganglioneuroblastoma" in str(image.fpath):
uri = image.uri.replace("\\", "/")
filename = uri.split("/")[-1]
if "\\rawimages\\" in str(image.fpath):
target_file = raw_folder + "/" + filename
if not os.path.exists(target_file):
image_data = imread(uri)
imsave(target_file, image_data)
if "\\groundtruth\\" in str(image.fpath):
target_file = groundtruth_folder + "/" + filename
if not os.path.exists(target_file):
image_data = imread(uri)
imsave(target_file, image_data)
C:\Users\haase\AppData\Local\Temp\ipykernel_26092\2091960599.py:14: UserWarning: ../../data/S-BIAD634/groundtruth/Ganglioneuroblastoma_0.tif is a low contrast image
imsave(target_file, image_data)
C:\Users\haase\AppData\Local\Temp\ipykernel_26092\2091960599.py:14: UserWarning: ../../data/S-BIAD634/groundtruth/Ganglioneuroblastoma_1.tif is a low contrast image
imsave(target_file, image_data)
C:\Users\haase\AppData\Local\Temp\ipykernel_26092\2091960599.py:14: UserWarning: ../../data/S-BIAD634/groundtruth/Ganglioneuroblastoma_10.tif is a low contrast image
imsave(target_file, image_data)
C:\Users\haase\AppData\Local\Temp\ipykernel_26092\2091960599.py:14: UserWarning: ../../data/S-BIAD634/groundtruth/Ganglioneuroblastoma_2.tif is a low contrast image
imsave(target_file, image_data)
C:\Users\haase\AppData\Local\Temp\ipykernel_26092\2091960599.py:14: UserWarning: ../../data/S-BIAD634/groundtruth/Ganglioneuroblastoma_3.tif is a low contrast image
imsave(target_file, image_data)
C:\Users\haase\AppData\Local\Temp\ipykernel_26092\2091960599.py:14: UserWarning: ../../data/S-BIAD634/groundtruth/Ganglioneuroblastoma_4.tif is a low contrast image
imsave(target_file, image_data)
C:\Users\haase\AppData\Local\Temp\ipykernel_26092\2091960599.py:14: UserWarning: ../../data/S-BIAD634/groundtruth/Ganglioneuroblastoma_6.tif is a low contrast image
imsave(target_file, image_data)
C:\Users\haase\AppData\Local\Temp\ipykernel_26092\2091960599.py:14: UserWarning: ../../data/S-BIAD634/groundtruth/Ganglioneuroblastoma_7.tif is a low contrast image
imsave(target_file, image_data)
C:\Users\haase\AppData\Local\Temp\ipykernel_26092\2091960599.py:14: UserWarning: ../../data/S-BIAD634/groundtruth/Ganglioneuroblastoma_8.tif is a low contrast image
imsave(target_file, image_data)
C:\Users\haase\AppData\Local\Temp\ipykernel_26092\2091960599.py:14: UserWarning: ../../data/S-BIAD634/groundtruth/Ganglioneuroblastoma_9.tif is a low contrast image
imsave(target_file, image_data)
Nous pouvons ensuite vérifier quels fichiers sont arrivés.
for f in os.listdir(raw_folder):
print(f)
Ganglioneuroblastoma_0.tif
Ganglioneuroblastoma_1.tif
Ganglioneuroblastoma_10.tif
Ganglioneuroblastoma_2.tif
Ganglioneuroblastoma_3.tif
Ganglioneuroblastoma_4.tif
Ganglioneuroblastoma_6.tif
Ganglioneuroblastoma_7.tif
Ganglioneuroblastoma_8.tif
Ganglioneuroblastoma_9.tif
for f in os.listdir(groundtruth_folder):
print(f)
Ganglioneuroblastoma_0.tif
Ganglioneuroblastoma_1.tif
Ganglioneuroblastoma_10.tif
Ganglioneuroblastoma_2.tif
Ganglioneuroblastoma_3.tif
Ganglioneuroblastoma_4.tif
Ganglioneuroblastoma_6.tif
Ganglioneuroblastoma_7.tif
Ganglioneuroblastoma_8.tif
Ganglioneuroblastoma_9.tif
Exercice#
Téléchargez toutes les images avec “Neuroblastoma” dans leur nom et téléversez-les dans un dossier dans l’owncloud. Ne téléchargez pas et ne téléversez pas les fichiers qui existent déjà.