andreped commited on
Commit
d4d0d98
·
2 Parent(s): 4dd1480 41031e2

Merge pull request #21 from jpdefrutos/master

Browse files
.github/workflows/build.yml CHANGED
@@ -2,9 +2,11 @@ name: Build
2
 
3
  on:
4
  push:
5
- branches: [ master ]
 
6
  pull_request:
7
- branches: [ master ]
 
8
 
9
  jobs:
10
  build:
@@ -72,10 +74,14 @@ jobs:
72
  gdown https://drive.google.com/uc?id=1shjSrFjS4PHE5sTku30PZTLPZpGu24o3
73
  gdown https://drive.google.com/uc?id=1bNmls5o0Rxw5HvBF1IYnEzmpysYJaywN
74
 
75
- - name: Test inference
76
  run: |
77
  livermask --input samples --output samples --verbose --vessels
78
 
 
 
 
 
79
  conda:
80
  needs: build
81
  runs-on: ${{ matrix.os }}
 
2
 
3
  on:
4
  push:
5
+ branches:
6
+ - "*"
7
  pull_request:
8
+ branches:
9
+ - "*"
10
 
11
  jobs:
12
  build:
 
74
  gdown https://drive.google.com/uc?id=1shjSrFjS4PHE5sTku30PZTLPZpGu24o3
75
  gdown https://drive.google.com/uc?id=1bNmls5o0Rxw5HvBF1IYnEzmpysYJaywN
76
 
77
+ - name: Test inference .nii
78
  run: |
79
  livermask --input samples --output samples --verbose --vessels
80
 
81
+ - name: Test inference .nii.gz
82
+ run: |
83
+ livermask --input samples --output samples --verbose --vessels --extension .nii.gz
84
+
85
  conda:
86
  needs: build
87
  runs-on: ${{ matrix.os }}
README.md CHANGED
@@ -53,6 +53,7 @@ livermask --input path-to-input --output path-to-output
53
  | `--cpu` | to disable the GPU (force computations on CPU only) |
54
  | `--verbose` | to enable verbose |
55
  | `--vessels` | to segment vessels |
 
56
 
57
  ### Using code directly:
58
  If you wish to use the code directly (not as a CLI and without installing), you can run this command:
@@ -61,7 +62,7 @@ python -m livermask.livermask --input path-to-input --output path-to-output
61
  ```
62
 
63
  ## DICOM/NIfTI format
64
- Pipeline assumes input is in the NIfTI format, and output a binary volume in the same format (.nii).
65
  DICOM can be converted to NIfTI using the CLI [dcm2niix](https://github.com/rordenlab/dcm2niix), as such:
66
  ```
67
  dcm2niix -s y -m y -d 1 "path_to_CT_folder" "output_name"
 
53
  | `--cpu` | to disable the GPU (force computations on CPU only) |
54
  | `--verbose` | to enable verbose |
55
  | `--vessels` | to segment vessels |
56
+ | `--extension` | of the output file (default: .nii) |
57
 
58
  ### Using code directly:
59
  If you wish to use the code directly (not as a CLI and without installing), you can run this command:
 
62
  ```
63
 
64
  ## DICOM/NIfTI format
65
+ Pipeline assumes input is in the NIfTI format, and output a binary volume in the same format (.nii or .nii.gz).
66
  DICOM can be converted to NIfTI using the CLI [dcm2niix](https://github.com/rordenlab/dcm2niix), as such:
67
  ```
68
  dcm2niix -s y -m y -d 1 "path_to_CT_folder" "output_name"
livermask/livermask.py CHANGED
@@ -54,15 +54,15 @@ def func(path, output, cpu, verbose, vessels, extension):
54
 
55
  for curr in tqdm(paths, "CT:"):
56
  # check if current file is a nifti file, if not, skip
57
- if not curr.endswith(".nii") or not curr.endswith(".nii.gz"):
58
- continue
59
-
60
- # perform liver parenchyma segmentation, launch it in separate process to properly clear memory
61
- pred = liver_segmenter_wrapper(curr, output, cpu, verbose, multiple_flag, name, extension)
62
-
63
- if vessels:
64
- # perform liver vessel segmentation
65
- vessel_segmenter(curr, output, cpu, verbose, multiple_flag, pred, name_vessel, extension)
66
 
67
 
68
  def main():
 
54
 
55
  for curr in tqdm(paths, "CT:"):
56
  # check if current file is a nifti file, if not, skip
57
+ if curr.endswith(".nii") or curr.endswith(".nii.gz"):
58
+ # perform liver parenchyma segmentation, launch it in separate process to properly clear memory
59
+ pred = liver_segmenter_wrapper(curr, output, cpu, verbose, multiple_flag, name, extension)
60
+
61
+ if vessels:
62
+ # perform liver vessel segmentation
63
+ vessel_segmenter(curr, output, cpu, verbose, multiple_flag, pred, name_vessel, extension)
64
+ else:
65
+ log.info("Unsuported file: " + curr)
66
 
67
 
68
  def main():
livermask/utils/process.py CHANGED
@@ -132,7 +132,7 @@ def liver_segmenter(params):
132
  raise "Caught KeyboardInterrupt, terminating worker"
133
 
134
 
135
- def vessel_segmenter(curr, output, cpu, verbose, multiple_flag, liver_mask, name_vessel):
136
  # check if cupy is available, if not, set cpu=True
137
  try:
138
  import cupy
@@ -226,6 +226,6 @@ def vessel_segmenter(curr, output, cpu, verbose, multiple_flag, liver_mask, name
226
  img = nib.Nifti1Image(pred, affine=resampled_volume.affine)
227
  resampled_lab = resample_from_to(img, nib_volume, order=0)
228
  if multiple_flag:
229
- nib.save(resampled_lab, output + "/" + curr.split("/")[-1].split(".")[0] + "-vessels.nii")
230
  else:
231
- nib.save(resampled_lab, output + "-vessels.nii")
 
132
  raise "Caught KeyboardInterrupt, terminating worker"
133
 
134
 
135
+ def vessel_segmenter(curr, output, cpu, verbose, multiple_flag, liver_mask, name_vessel, extension):
136
  # check if cupy is available, if not, set cpu=True
137
  try:
138
  import cupy
 
226
  img = nib.Nifti1Image(pred, affine=resampled_volume.affine)
227
  resampled_lab = resample_from_to(img, nib_volume, order=0)
228
  if multiple_flag:
229
+ nib.save(resampled_lab, output + "/" + curr.split("/")[-1].split(".")[0] + "-vessels" + extension)
230
  else:
231
+ nib.save(resampled_lab, output + "-vessels" + extension)