Skip to content

Commit 6612461

Browse files
committed
DOC README update
1 parent 0be294e commit 6612461

File tree

9 files changed

+23
-15
lines changed

9 files changed

+23
-15
lines changed

README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,21 @@ segmentations in nifti format.
3232

3333
### Introductory example
3434

35-
Given a segmentation `my_input_data/my_segm.nii.gz` you want to change the labels values from [1, 2, 3, 4, 5, 6] to [2, 12, 4, 7, 5, 6]. Then:
35+
Given a segmentation `my_input_folder_path/my_segm.nii.gz` imagine you want to change the labels values from [1, 2, 3, 4, 5, 6] to [2, 12, 4, 7, 5, 6]
36+
and save the result in `my_output_folder_path/my_new_segm.nii.gz`. Then:
3637

3738
```python
3839
import nilabels as nis
3940

41+
# option 1
42+
nis_app = nis.App('my_input_folder_path', 'my_output_folder_path')
43+
nis_app.manipulate_labels.relabel('my_segm.nii.gz', 'my_new_segm.nii.gz',
44+
[1, 2, 3, 4, 5, 6], [2, 12, 4, 7, 5, 6])
4045

41-
nis_app = nis.App('my_input_data')
42-
nis_app.manipulate.relabel('my_segm.nii.gz', 'my_new_segm.nii.gz', [1, 2, 3, 4, 5, 6], [2, 12, 4, 7, 5, 6])
46+
# option 2
47+
nis_app = nis.App()
48+
nis_app.manipulate_labels.relabel('my_input_folder_path/my_segm.nii.gz', 'my_output_folder_path/my_new_segm.nii.gz',
49+
[1, 2, 3, 4, 5, 6], [2, 12, 4, 7, 5, 6])
4350
```
4451

4552
### How to install (in development mode)

nilabels/agents/fuser.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ def seg_LabFusion(self, pfi_target, pfi_result, list_pfi_segmentations, list_pfi
1919
prepare_data_only=False, seg_output_name='res_4d_seg', warp_output_name='res_4d_warp',
2020
output_tag=''):
2121
"""
22+
Stack and fuse anatomical images and segmentations in a single command.
23+
Based on NiftySeg if prepare_data_only is False.
2224
:param pfi_target: path to file to the target of the segmentation
2325
:param pfi_result: path to file where to store the result.
2426
:param list_pfi_segmentations: list of the segmentations to fuse

nilabels/agents/intensities_manipulator.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ def __init__(self, input_data_folder=None, output_data_folder=None, path_label_d
2121
self.pfo_out = output_data_folder
2222
self.path_label_descriptor = path_label_descriptor
2323

24-
# TODO embed path label descriptors.
2524
def normalise_below_label(self, filename_image_in, filename_image_out, filename_segm, labels, stats=np.median):
2625
"""
2726

nilabels/agents/measurer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def global_dist(self, segm_1_filename, segm_2_filename, where_to_save=None,
139139
return se_global_distances
140140

141141
def topology(self):
142-
# WIP: island detections, graph detections, cc detections from detector tools
142+
# TODO: island detections, graph detections, cc detections from detector tools
143143
print('topology for {} is in the TODO list!'.format(self.__class__))
144144

145145
def groupwise_global_measures_comparisons(self, list_path_A, list_path_B, pfo_where_to_save,

nilabels/tools/caliber/distances.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import pandas as pa
33
from scipy import ndimage as nd
44

5-
from nilabels.tools.detections.contours import contour_from_array_at_label_l
5+
from nilabels.tools.detections.contours import contour_from_array_at_label
66

77

88
# --- Auxiliaries
@@ -186,8 +186,8 @@ def symmetric_contour_distance_one_label(im1, im2, lab, return_mm3, formula='nor
186186
if np.count_nonzero(arr1) == 0 or np.count_nonzero(arr2) == 0:
187187
return np.nan
188188

189-
arr1_contour = contour_from_array_at_label_l(arr1, 1)
190-
arr2_contour = contour_from_array_at_label_l(arr2, 1)
189+
arr1_contour = contour_from_array_at_label(arr1, 1)
190+
arr2_contour = contour_from_array_at_label(arr2, 1)
191191

192192
if return_mm3:
193193
dtb1 = nd.distance_transform_edt(1 - arr1_contour, sampling=list(np.diag(im1.affine[:3, :3])))

nilabels/tools/defs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
root_dir = os.path.dirname(os.path.dirname(os.path.abspath(os.path.dirname(__file__))))
55

66
info = {
7-
"name": "LABelsToolkit",
7+
"name": "NiLabels",
88
"version": "0.1",
99
"description": "",
1010
"repository": {

nilabels/tools/detections/contours.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@
33
from nilabels.tools.aux_methods.utils_nib import set_new_data
44

55

6-
def contour_from_array_at_label_l(im_arr, l, thr=0.3, omit_axis=None, verbose=0):
6+
def contour_from_array_at_label(im_arr, lab, thr=0.3, omit_axis=None, verbose=0):
77
"""
88
Get the contour of a single label
99
:param im_arr: input array with segmentation
10-
:param l: considered label
10+
:param lab: considered label
1111
:param thr: threshold (default 0.3) increase to increase the contour thickness.
1212
:param omit_axis: a directional axis preference for the contour creation, to avoid "walls" when scrolling
1313
the 3d image in a particular direction. None if no preference axis is expected.
1414
:param verbose:
1515
:return:
1616
"""
1717
if verbose > 0:
18-
print('eroding label {}'.format(l))
19-
array_label_l = im_arr == l
18+
print('eroding label {}'.format(lab))
19+
array_label_l = im_arr == lab
2020
assert isinstance(array_label_l, np.ndarray)
2121
gra = np.gradient(array_label_l.astype(np.bool).astype(np.float64))
2222
if omit_axis is None:
@@ -46,6 +46,6 @@ def contour_from_segmentation(im_segm, omit_axis=None, verbose=0):
4646
output_arr = np.zeros_like(im_segm.get_data(), dtype=im_segm.get_data_dtype())
4747

4848
for la in list_labels:
49-
output_arr += contour_from_array_at_label_l(im_segm.get_data(), la, omit_axis=omit_axis, verbose=verbose)
49+
output_arr += contour_from_array_at_label(im_segm.get_data(), la, omit_axis=omit_axis, verbose=verbose)
5050

5151
return set_new_data(im_segm, output_arr.astype(np.bool) * im_segm.get_data(), new_dtype=im_segm.get_data_dtype())

nilabels/tools/image_colors_manipulations/cutter.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ def apply_a_mask_nib(im_input, im_mask):
4949
"""
5050
assert len(im_mask.shape) == 3
5151

52+
# TODO correct this: make the cut_4d_volume_with_a_1_slice_mask merged hrer
5253
if not im_mask.shape == im_input.shape[:3]:
5354
msg = 'Provided mask and image does not have compatible dimension: {0} and {1}'.format(
5455
im_input.shape, im_mask.shape)

nilabels/tools/image_colors_manipulations/normaliser.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ def intensities_normalisation_linear(im_input, im_segm, im_mask_foreground=None,
7474
return set_new_data(im_input, im_mask_foreground_data * (a * im_input.get_data() + b))
7575

7676

77-
7877
def mahalanobis_distance_map(im, im_mask=None, trim=False):
7978
"""
8079
From an image to its Mahalanobis distance map

0 commit comments

Comments
 (0)