Exemplo n.º 1
0
    def _openFID(self):
        """ QT slot that launches the files selector to open a Varian FID file
        
        Selecting the top level \*.fid folder will open it correctly, loading
        both the image data and the procpar file.
        
        """
        # launch the folder selection dialog
        if platform.system() == 'Windows':
            home = os.environ['USERPROFILE']
        elif platform.system() == 'Linux':
            home = os.environ['HOME']

        FID = QtGui.QFileDialog.getExistingDirectory(caption="Open FID",
                                                     directory=home,
                                        options=QtGui.QFileDialog.ShowDirsOnly)
        # Open the FID file
        if FID:
            self.dic, self.data = ng.varian.read(str(FID))
            temp = (float(self.dic['procpar']['lpe']['values'][0]) /
                    float(self.dic['procpar']['lro']['values'][0]))
            self.aspectRatio = temp*(2*float(
                               self.dic['procpar']['nv']['values'][0]) /
                               float(self.dic['procpar']['np']['values'][0]))

            # Add a DC offset corection filter
            self.filterStack.insert(0, filt.makeDCO(Size=10))
            # apply any default filters and recon
            self.updateAll()
Exemplo n.º 2
0
    def _updateFilter(self):
        """Update the filter in the stack and redisplay"""
        if self.filterStack == []:
            return
        window = self.FILTER_NAMES[str(self.windowCB.currentText())]
        if (window == 'chebwin') or (window == 'gaussian') or \
                (window == 'kaiser') or (window == 'slepian'):
            window = (window, self.shapeSB.value())

        if window == 'DC Offset':
            workingFilter = filt.makeDCO()

        elif self.lowpassRB.isChecked():
            workingFilter = \
                filt.makeLPF(Window=window,
                             Dim=self.dim,
                             Diameter=self.diameterSB.value(),
                             Outer=self.outerRB.isChecked(),
                             Cont=self.percentRB.isChecked())
        elif self.highpassRB.isChecked():
            workingFilter = \
                filt.makeHPF(Window=window,
                             Dim=self.dim,
                             Diameter=self.diameterSB.value(),
                             Outer=self.outerRB.isChecked(),
                             Cont=self.percentRB.isChecked())

        elif self.cbandstopRB.isChecked():
            workingFilter = \
                filt.makeBSF(Window=window,
                             Dim=self.dim,
                             Radius=self.diameterSB.value(),
                             Diameter=self.widthSB.value(),
                             Cont=self.percentRB.isChecked())

        elif self.vbandstopRB.isChecked():
            workingFilter = \
                filt.makeVBSF(Window=window,
                              Dim=self.dim,
                              Center=self.hcenterSB.value(),
                              Width=self.widthSB.value())

        elif self.hbandstopRB.isChecked():
            workingFilter = \
                filt.makeHBSF(Window=window,
                              Dim=self.dim,
                              Center=self.vcenterSB.value(),
                              Width=self.widthSB.value())

        elif self.notchRB.isChecked():
            center = (self.vcenterSB.value(), self.hcenterSB.value())
            workingFilter = filt.makeNF(Window=window,
                                        Dim=self.dim,
                                        Center=center,
                                        Width=self.widthSB.value())

        self.filterDisplay.imshow(workingFilter.function(np.ones(self.dim)))
        index = self.filterList.currentRow()
        self.filterStack[index] = workingFilter
        self._updateList()
        self.filterList.setCurrentRow(index)