Skip to content

Commit

Permalink
Merge pull request #81 from ofgulban/devel
Browse files Browse the repository at this point in the history
Fix smoothing filter bug
  • Loading branch information
ofgulban authored Mar 21, 2019
2 parents 8061bd4 + 1afb33d commit 88b2421
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 19 deletions.
7 changes: 5 additions & 2 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ build: false

environment:
matrix:
- PYTHON_VERSION: 3.6
- PYTHON_VERSION: 3.7
MINICONDA: C:\Miniconda

init:
Expand All @@ -12,8 +12,11 @@ install:
- "set PATH=%MINICONDA%;%MINICONDA%\\Scripts;%PATH%"
- conda config --set always_yes yes --set changeps1 no
- conda update -q conda
- "conda env create --force -f environment.yml python=3.6"
- conda config --add channels conda-forge
- conda info -a
- "conda env create -q -n segmentator python=%PYTHON_VERSION% --file requirements.txt"
- activate segmentator
- pip install compoda
- python setup.py install

test_script:
Expand Down
2 changes: 2 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ omit =
*config*
*tests/*
segmentator/future/*
segmentator/cython/*
*ui.py
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![DOI](https://zenodo.org/badge/59303623.svg)](https://zenodo.org/badge/latestdoi/59303623) [![Build Status](https://travis-ci.org/ofgulban/segmentator.svg?branch=master)](https://travis-ci.org/ofgulban/segmentator) [![Build status](https://ci.appveyor.com/api/projects/status/lkxp4y5ahssqv6ng?svg=true)](https://ci.appveyor.com/project/ofgulban/segmentator) [![codecov](https://codecov.io/gh/ofgulban/segmentator/branch/master/graph/badge.svg)](https://codecov.io/gh/ofgulban/segmentator) [![Code Health](https://landscape.io/github/ofgulban/segmentator/master/landscape.svg?style=flat)](https://landscape.io/github/ofgulban/segmentator/master) [![Gitter chat](https://badges.gitter.im/gitterHQ/gitter.png)](https://gitter.im/segmentator/Lobby)
[![DOI](https://zenodo.org/badge/59303623.svg)](https://zenodo.org/badge/latestdoi/59303623) [![Build Status](https://travis-ci.org/ofgulban/segmentator.svg?branch=master)](https://travis-ci.org/ofgulban/segmentator) [![Build status](https://ci.appveyor.com/api/projects/status/lkxp4y5ahssqv6ng?svg=true)](https://ci.appveyor.com/project/ofgulban/segmentator) [![codecov](https://codecov.io/gh/ofgulban/segmentator/branch/master/graph/badge.svg)](https://codecov.io/gh/ofgulban/segmentator) [![Gitter chat](https://badges.gitter.im/gitterHQ/gitter.png)](https://gitter.im/segmentator/Lobby)

# Segmentator

Expand Down Expand Up @@ -27,7 +27,6 @@ The goal is to provide a complementary tool to the already available brain tissu
| [Compoda](https://github.com/ofgulban/compoda) | 0.3.3 |

## Installation & Quick Start
- Make sure you have [**pip**](https://en.wikipedia.org/wiki/Pip_(package_manager)) installed if you are using [**Python 2.7**](https://www.python.org/download/releases/2.7/).
- Download [the latest release](https://github.com/ofgulban/segmentator/releases) and unzip it.
- Change directory in your command line:
```
Expand Down
11 changes: 0 additions & 11 deletions environment.yml

This file was deleted.

1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ scipy==1.0.0
matplotlib==2.2.2
nibabel==2.2.1
pytest-cov==2.5.1
compoda>=0.3
1 change: 1 addition & 0 deletions segmentator/config_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@
edge_thr = 0.001
gamma = 1
downsampling = 0
no_nonpositive_mask = False
8 changes: 6 additions & 2 deletions segmentator/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from __future__ import division
import os
import numpy as np
import config_filters as cfg
import segmentator.config_filters as cfg
from nibabel import load, Nifti1Image, save
from numpy.linalg import eigh
from scipy.ndimage import gaussian_filter
Expand Down Expand Up @@ -71,7 +71,11 @@ def QC_export(image, basename, identifier, nii):
else:
pass

idx_msk_flat = ima.flatten() != 0
if cfg.no_nonpositive_mask: # TODO: work in progress
idx_msk_flat = np.ones(ima.size, dtype=bool)
else: # mask out non positive voxels
idx_msk_flat = ima.flatten() > 0

dims = ima.shape

# The main loop
Expand Down
5 changes: 5 additions & 0 deletions segmentator/filters_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ def main():
help="(!WIP!) Downsampling factor, use integers > 1. E.g. factor of 2 \
reduces the amount of voxels 8 times."
)
parser.add_argument(
"--no_nonpositive_mask", action='store_true',
help="(!WIP!) Do not mask out non-positive values."
)

# set cfg file variables to be accessed from other scripts
args = parser.parse_args()
Expand All @@ -85,6 +89,7 @@ def main():
cfg.nr_iterations = args.nr_iterations
cfg.save_every = args.save_every
cfg.downsampling = args.downsampling
cfg.no_nonpositive_mask = args.no_nonpositive_mask

welcome_str = 'Segmentator {}'.format(__version__)
welcome_decor = '=' * len(welcome_str)
Expand Down
2 changes: 1 addition & 1 deletion segmentator/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
from nibabel import load, Nifti1Image, save
from scipy.ndimage import convolve
from time import time
from segmentator.deriche_prepare import Deriche_Gradient_Magnitude


def sub2ind(array_shape, rows, cols):
Expand Down Expand Up @@ -304,6 +303,7 @@ def compute_gradient_magnitude(ima, method='scharr'):
gra = np.asarray(np.gradient(ima))
gra_mag = np.sqrt(np.sum(np.power(gra, 2.), axis=0))
elif method.lower() == 'deriche':
from segmentator.deriche_prepare import Deriche_Gradient_Magnitude
alpha = cfg.deriche_alpha
print(' Selected alpha: {}'.format(alpha))
ima = np.ascontiguousarray(ima, dtype=np.float32)
Expand Down

0 comments on commit 88b2421

Please sign in to comment.