Skip to content

Commit 9f80c29

Browse files
Merge pull request #40 from TeamNCMC/duplicate-examples
Duplicate examples
2 parents 6bda783 + eb93e00 commit 9f80c29

File tree

7 files changed

+150
-885
lines changed

7 files changed

+150
-885
lines changed

cuisto/config.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
55
"""
66

7+
import os
78
import tomllib
89
import warnings
910

@@ -62,9 +63,10 @@ def __init__(self, config_file):
6263
def get_blacklist(self):
6364
"""Wraps cuisto.utils.get_blacklist."""
6465

65-
self.atlas["blacklist"] = utils.get_blacklist(
66-
self.files["blacklist"], self.bg_atlas
67-
)
66+
if os.path.isfile(self.files["blacklist"]):
67+
self.atlas["blacklist"] = utils.get_blacklist(
68+
self.files["blacklist"], self.bg_atlas
69+
)
6870

6971
def get_leaves_list(self):
7072
"""Wraps utils.get_leaves_list."""

examples/cells_distributions.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,24 +24,30 @@
2424

2525
from pathlib import Path
2626

27+
import matplotlib.pyplot as plt
2728
import pandas as pd
2829

2930
import cuisto
3031

3132
# Full path to your configuration file, edited according to your need beforehand
32-
wdir = Path(__file__).parent.parent
33-
config_file = wdir / "resources" / "demo_config_cells.toml"
33+
wdir = Path(__file__).parent.parent / "resources"
34+
config_file = wdir / "demo_config_cells.toml"
3435

3536
# - Files
3637
# animal identifier
3738
animal = "animalid0"
3839
# set the full path to the annotations tsv file from QuPath
39-
annotations_file = "../../resources/cells_measurements_annotations.tsv"
40+
annotations_file = wdir / "cells_measurements_annotations.tsv"
4041
# set the full path to the detections tsv file from QuPath
41-
detections_file = "../../resources/cells_measurements_detections.tsv"
42+
detections_file = wdir / "cells_measurements_detections.tsv"
4243

4344
# get configuration
4445
cfg = cuisto.config.Config(config_file)
46+
# update configuration file paths (so that this example can self-run)
47+
cfg.files["blacklist"] = wdir / "demo_atlas_blacklist_brain.toml"
48+
cfg.files["fusion"] = wdir / "demo_atlas_fusion_brain.toml"
49+
cfg.files["infos"] = wdir / "demo_info_cells.toml"
50+
cfg.get_blacklist()
4551

4652
# read data
4753
df_annotations = pd.read_csv(annotations_file, index_col="Object ID", sep="\t")
@@ -87,3 +93,5 @@
8793

8894
# plot heatmap (all types of cells pooled)
8995
fig_heatmap = cuisto.display.plot_2D_distributions(df_coordinates, cfg)
96+
97+
plt.show()

examples/density_map.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,17 @@
1515
# Find this script as a notebook in the documentation :
1616
# https://teamncmc.github.io/cuisto/demo_notebooks/density_map.html
1717

18+
from pathlib import Path
19+
1820
import brainglobe_heatmap as bgh
1921
import matplotlib.pyplot as plt
2022
import numpy as np
2123
import pandas as pd
2224
import seaborn as sns
2325

2426
# path to the exported measurements from QuPath
25-
filename = "../resources/cells_measurements_detections.tsv"
27+
wdir = Path(__file__).parent.parent / "resources"
28+
filename = wdir / "cells_measurements_detections.tsv"
2629

2730
# Settings
2831
# atlas to use
@@ -160,3 +163,5 @@
160163
plt.yticks([])
161164
plt.plot([0.5, 1.5], [0.5, 0.5], "k", linewidth=3)
162165
plt.text(0.5, 0.4, "1 mm")
166+
167+
plt.show()

0 commit comments

Comments
 (0)