Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
STYLE: multiply_stack_with_mask -> multiply application
- Loading branch information
Michael Ebner
committed
Jan 31, 2019
1 parent
3bc580b
commit 89af2ce
Showing
5 changed files
with
61 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
## | ||
# \file multiply.py | ||
# \brief Script multiply images with each other. | ||
# | ||
# \author Michael Ebner (michael.ebner.14@ucl.ac.uk) | ||
# \date October 2017 | ||
# | ||
|
||
import os | ||
import SimpleITK as sitk | ||
|
||
import pysitk.python_helper as ph | ||
|
||
import niftymic.base.data_writer as dw | ||
from niftymic.utilities.input_arparser import InputArgparser | ||
|
||
|
||
def main(): | ||
|
||
input_parser = InputArgparser( | ||
description="Multiply images. " | ||
"Pixel type is determined by first given image.", | ||
) | ||
|
||
input_parser.add_filenames(required=True) | ||
input_parser.add_output(required=True) | ||
input_parser.add_verbose(default=0) | ||
|
||
args = input_parser.parse_args() | ||
input_parser.print_arguments(args) | ||
|
||
if len(args.filenames) < 2: | ||
raise IOError("At least two images must be provided") | ||
|
||
out_sitk = sitk.ReadImage(args.filenames[0]) | ||
for f in args.filenames[1:]: | ||
im_sitk = sitk.Cast(sitk.ReadImage(f), out_sitk.GetPixelIDValue()) | ||
out_sitk = out_sitk * im_sitk | ||
|
||
dw.DataWriter.write_image(out_sitk, args.output) | ||
|
||
if args.verbose: | ||
args.filenames.insert(0, args.output) | ||
ph.show_niftis(args.filenames) | ||
|
||
if __name__ == '__main__': | ||
main() |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
# -*- coding: utf-8 -*- | ||
import sys | ||
|
||
from niftymic.application.multiply_stack_with_mask import main | ||
from niftymic.application.multiply import main | ||
|
||
if __name__ == "__main__": | ||
sys.exit(main()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters