@@ -0,0 +1,2665 @@
+# Author: Ashley Anderson III %3Caganders3@gmail.com%3E%0A# Date: 2016-01-25 13:58%0A%0Aimport numpy as np%0Aimport gpi%0A%0Aclass ExternalNode(gpi.NodeAPI):%0A    %22%22%22Transform coordinates from BNI conventions to BART conventions.%0A%0A    INPUT:%0A        in - a numpy arrary of k-space coordinates in the BNI convention%0A            i.e. (-0.5, 0.5), dimensions: %5Breadouts, pts, xy(z)%5D%0A    OUTPUT:%0A        out - a numpy array of k-space coordinates in the BART convention%0A            i.e. (-mtx/2, mtx/2), dimensions: %5Bzyx, pts, readouts%5D%0A    WIDGETS:%0A        mtx - the resulting matrix size (assumed square/cubic)%0A    %22%22%22%0A%0A    # initialize the UI - add widgets and input/output ports%0A    def initUI(self):%0A        # Widgets%0A        self.addWidget('SpinBox', 'mtx', val=128, min=1, max=1024)%0A        # self.addWidget('DoubleSpinBox', 'bar', val=10, min=0, max=100)%0A        # self.addWidget('PushButton', 'baz', toggle=True)%0A        # self.addWidget('ExclusivePushButtons', 'qux',%0A        #              buttons=%5B'Antoine', 'Colby', 'Trotter', 'Adair'%5D, val=1)%0A%0A        # IO Ports%0A        self.addInPort('in', 'NPYarray', ndim=3)%0A        self.addOutPort('out', 'NPYarray', dtype=np.complex64, ndim=3)%0A%0A%0A    # validate the data - runs immediately before compute%0A    # your last chance to show/hide/edit widgets%0A    # return 1 if the data is not valid - compute will not run%0A    # return 0 if the data is valid - compute will run%0A    def validate(self):%0A        in_data = self.getData('in')%0A%0A        # TODO: make sure the input data is valid%0A        # %5Byour code here%5D%0A%0A        return 0%0A%0A    # process the input data, send it to the output port%0A    # return 1 if the computation failed%0A    # return 0 if the computation was successful%0A    def compute(self):%0A        coords = self.getData('in').copy()%0A        mtx = self.getVal('mtx')%0A%0A        # just transpose first to reverse dimensions%0A        coords = coords.T%0A%0A        # adjust by the matrix size%0A        # TODO: account for %22true resolution%22%0A        coords *= mtx%0A%0A        # reverse the xyz dimension%0A        coords%5B:,...%5D = coords%5B::-1,...%5D%0A%0A        # pad the z-dimension with zeros if the trajectory is 2D%0A        if coords.shape%5B0%5D == 2:%0A            coords = np.pad(coords,%0A                            ((0,1), (0,0), (0,0)),%0A                            mode='constant',%0A                            constant_values=0)%0A%0A        # if the trajectory is not 3D at this point, something has gone wrong%0A        if coords.shape%5B0%5D != 3:%0A            self.log.warn(%22The final dimensions of the input data must be 2 (xy), or 3 (xyz).%22)%0A            return 1%0A%0A        self.setData('out', np.require(coords, dtype=np.complex64))%0A%0A        return 0%0A

Add node to convert BNI trajectories (e.g. from SpiralCoords) to BART trajectories.