示例#1
0
    def __init__(self, id, name):
        try:
            ivw.Processor.__init__(self, id, name)

            self.slider = IntProperty("slider", "slider", 0, 0, 100, 1)
            self.addProperty(self.slider, owner=False)
            self.pattern = FilePatternProperty("pattern", "pattern", "", "")
            self.addProperty(self.pattern)

            self.out = FileProperty("out", "out", "", "")
            self.addProperty(self.out)
            self.out.readOnly = True

            self.triggerLoad = ButtonProperty("load", "Load")
            self.addProperty(self.triggerLoad)

            def patternChange():
                self.slider.maxValue = len(self.pattern.fileList)

            self.pattern.onChange(patternChange)

            def sliderChange():
                if self.slider.value < len(self.pattern.fileList):
                    self.out.value = self.pattern.fileList[self.slider.value]
                    self.load.press()

            self.slider.onChange(sliderChange)
        except Exception as e:
            print(f"Error: {e}")
示例#2
0
class FileGlob(ivw.Processor):
    def __init__(self, id, name):
        try:
            ivw.Processor.__init__(self, id, name)

            self.slider = IntProperty("slider", "slider", 0, 0, 100, 1)
            self.addProperty(self.slider, owner=False)
            self.pattern = FilePatternProperty("pattern", "pattern", "", "")
            self.addProperty(self.pattern)

            self.out = FileProperty("out", "out", "", "")
            self.addProperty(self.out)
            self.out.readOnly = True

            self.triggerLoad = ButtonProperty("load", "Load")
            self.addProperty(self.triggerLoad)

            def patternChange():
                self.slider.maxValue = len(self.pattern.fileList)

            self.pattern.onChange(patternChange)

            def sliderChange():
                if self.slider.value < len(self.pattern.fileList):
                    self.out.value = self.pattern.fileList[self.slider.value]
                    self.load.press()

            self.slider.onChange(sliderChange)
        except Exception as e:
            print(f"Error: {e}")

    @staticmethod
    def processorInfo():
        return ivw.ProcessorInfo(classIdentifier="org.inviwo.FileGlob",
                                 displayName="FileGlob",
                                 category="Python",
                                 codeState=ivw.CodeState.Stable,
                                 tags=ivw.Tags.PY)

    def getProcessorInfo(self):
        return FileGlob.processorInfo()

    def initializeResources(self):
        pass

    def process(self):
        pass
    self.addOutport(ImageOutport("outport"))

if not "sample" in self.outports:
    self.addOutport(ImageOutport("sample"))

if not "off" in self.properties:
    self.addProperty(
        BoolProperty("off", "Off", True))

if not "display_input" in self.properties:
    self.addProperty(
        BoolProperty("display_input", "Show Input", True))

if not "sample_num" in self.properties:
    self.addProperty(
        IntProperty("sample_num", "Sample Number", 0)
    )
    self.getPropertyByIdentifier("sample_num").minValue = 0
    self.getPropertyByIdentifier("sample_num").maxValue = 63

def process(self):
    """Perform the model warping and output an image grid"""
    if self.getPropertyByIdentifier("off").value:
        print("Image warping is currently turned off")
        return 1

    start_time = time.time()

    if self.getPropertyByIdentifier("display_input").value:
        im_data = []
        for name in INPORT_LIST:
        self.addInport(ImageInport(name))

if not "outport" in self.outports:
    self.addOutport(ImageOutport("outport"))

if not "sample" in self.outports:
    self.addOutport(ImageOutport("sample"))

if not "off" in self.properties:
    self.addProperty(BoolProperty("off", "Off", True))

if not "display_input" in self.properties:
    self.addProperty(BoolProperty("display_input", "Show Input", True))

if not "sample_num" in self.properties:
    self.addProperty(IntProperty("sample_num", "Sample Number", 0))
    self.getPropertyByIdentifier("sample_num").minValue = 0
    self.getPropertyByIdentifier("sample_num").maxValue = 63


def process(self):
    """Perform the model warping and output an image grid"""
    if self.getPropertyByIdentifier("off").value:
        print("Image warping is currently turned off")
        return 1

    start_time = time.time()

    if self.getPropertyByIdentifier("display_input").value:
        im_data = []
        for name in INPORT_LIST:
示例#5
0
from inviwopy.data import Volume, TransferFunction

from math import ceil
import numpy as np

from random import random

if not "outport" in self.outports:
    self.addOutport(VolumeOutport("outport"))

if not "volinport" in self.inports:
    self.addInport(VolumeInport("volinport"))

if not "num_peaks" in self.properties:
    self.addProperty(
        IntProperty("num_peaks", "Number of peaks in Transfer Function", 3, 1,
                    20))

if not "start" in self.properties:
    self.addProperty(IntProperty("start", "Peak to start at", 3, 1, 20))

if not "tf" in self.properties:
    self.addProperty(
        #TransferFunctionProperty("tf", "Transfer Function", TransferFunction(),# self.inports.volinport)
        TransferFunctionProperty("tf", "Transfer Function",
                                 TransferFunction()))

if not "button" in self.properties:
    self.addProperty(ButtonProperty("button", "Generate TF"))


def random_colour():
                     InvalidationLevel.InvalidOutput,
                     PropertySemantics("PythonEditor")))

if not "use_scan_basis" in self.properties:
    self.addProperty(
        BoolProperty("use_scan_basis", "Use the scanned file basis", False,
                     InvalidationLevel.InvalidOutput,
                     PropertySemantics("PythonEditor")))

if not "basis" in self.properties:
    self.addProperty(
        FloatVec3Property("basis", "X, Y, Z basis scales", vec3(1.0),
                          vec3(0.0), vec3(1.0), vec3(0.001)))

if not "max" in self.properties:
    self.addProperty(IntProperty("max", "Defined data max", 600, 1, 1500))


def process(self):
    """
    The PythonScriptProcessor will call this process function whenever the processor process 
    function is called. The argument 'self' represents the PythonScriptProcessor.
    """
    if self.properties.use_nifti.value == True:
        print("Loading nii data at " + self.properties.location.value)
        img = nib.load(self.properties.location.value)
        print(img.header)
        print(img.get_data_dtype())
        data = img.get_fdata()
    else:
        print("Loading numpy data at " + self.properties.location.value)