def select_path_to_save_filter_results(self,
                                           data,
                                           save_filter_metadata=False):
        """ Opens a file dialog to select path for saving object filter results """

        FileDialog = QFileDialog()
        filter_results_file_location = FileDialog.getSaveFileName(
            self, "Select path to save filter results", "CSV Files (*.csv)")

        if not (filter_results_file_location[0] == ''):
            data.to_csv(filter_results_file_location[0])

        if save_filter_metadata:
            for c in self._main_model.rois.keys():

                filepath = pathlib.Path(filter_results_file_location[0])

                path = self.roi_to_path(self._main_model.rois[c][1])
                points = path.vertices
                roi_area = self.calculate_roi_area(points[:, 0], points[:, 1])

                with open(
                        pathlib.PurePath(filepath.parent,
                                         filepath.stem + "_metadata.txt"),
                        "a") as f:

                    f.write(str(c) + "\n")
                    f.write("x, y\n")
                    for i in np.arange(points.shape[0]):
                        f.write(
                            str(np.around(points[i, 0], decimals=1)) + "," +
                            str(np.around(points[i, 1], decimals=1)) + "\n")
                    f.write("\n")
                    f.write("Area (pixel^2)\n")
                    f.write(str(np.around(roi_area, decimals=1)) + "\n")
    def save_current_mask(self):

        FileDialog = QFileDialog()
        mask_file_location = FileDialog.getSaveFileName(
            self, "Select path to save current mask", "H5 Files (*.h5)")

        with h5py.File(mask_file_location[0], "w") as f:
            dset = f.create_dataset(
                "data",
                data=np.array(self._current_image_model.segmentation_image,
                              dtype=np.uint8))
예제 #3
0
    def loadFolder(self, inputCat=None, methode=None):
        """Méthode qui permet de charger un fichier et afficher dans le plainText"""
        directoryToOpen = os.getcwd()
        for key, folder in self.dicoFoldersCallibration.items():
            if folder != None:
                print(key, folder)
                directoryToOpen = folder
                break

        if methode == "clicked":
            pathdir = QFileDialog.getExistingDirectory(
                self,
                caption="Load the directory " + inputCat,
                directory=directoryToOpen)
            self.dicoObjectOpenLineEditCallibration[inputCat].setText(pathdir)
        elif methode == "write":
            pathdir = str(
                self.dicoObjectOpenLineEditCallibration[inputCat].text())

        if pathdir != "" and os.path.isdir(pathdir):
            self.dicoFoldersCallibration[inputCat] = pathdir
        else:
            self.dicoFoldersCallibration[inputCat] = ""
            self.dicoObjectOpenLineEditCallibration[inputCat].setText("")
            self.displayError(error="\"%s\" is not a valid Path \n" %
                              (pathdir))
        self.actualizeRunBouton()
        self.autocomplete_Folder()
예제 #4
0
 def __init__(self, parent=None):
     QMainWindow.__init__(self, parent=None)
     self.files = str(QFileDialog.getExistingDirectory(self, "Select ARRIRAW Clip Directory"))
     self.Error = QString("")
     if self.files != "":
         self.showdialog("Set New Roll Number")
     sys.exit(0)
 def select_resistance_json_file(self):
     """ Selects a json file to parse the resitance from """
     new_file_path_json = QFileDialog.getOpenFileName()[0]
     if not new_file_path_json == '' and new_file_path_json[
             -len('.json'):] == '.json':
         self.resistance_line.clear()
         self.resistance_json_path = new_file_path_json
예제 #6
0
 def selectCacheDir(self):
     selected_dir = QFileDialog.getExistingDirectory(
         self.settings, i18n("Open Directory"), "/",
         QFileDialog.ShowDirsOnly | QFileDialog.DontResolveSymlinks)
     if not selected_dir == '':
         if not selected_dir == self.settings.cacheDirPath.text():
             self.settings.cacheDirPath.setText(selected_dir)
             self.markChanged()
예제 #7
0
    def browse_path(self):
        filename = QFileDialog.getOpenFileName(self, 'Open pickler File', "",
                                               'Logs Files (*.*)')

        if isinstance(filename, tuple):
            filename = filename[0]
        if filename:
            self.ui.label_file_log_1.setText(filename)
 def select_json_file(self):
     """ Selects a json file to parse overall data from """
     new_file_path_json = QFileDialog.getOpenFileName()[0]
     if not new_file_path_json == '' and new_file_path_json[
             -len('.json'):] == '.json':
         self.clear_all_plots()
         self.file_path_json = new_file_path_json
         self.resistance_json_path = None
예제 #9
0
 def selectCacheDir(self):
     selected_dir = QFileDialog.getExistingDirectory(
         self.settings, i18n("Open Directory"), "/", QFileDialog.ShowDirsOnly | QFileDialog.DontResolveSymlinks
     )
     if not selected_dir == "":
         if not selected_dir == self.settings.cacheDirPath.text():
             self.settings.cacheDirPath.setText(selected_dir)
             self.markChanged()
    def load_analysis_file(self):
        """ Loads analysis file and calls updates to data models """

        FileDialog = QFileDialog()
        analysis_file_location = FileDialog.getOpenFileName(
            self, "Select object analysis data", "D:\\Austin\\",
            "CSV or Text Files (*csv *txt)")

        if os.path.isfile(analysis_file_location[0]):
            self._main_model.object_data = pd.read_csv(
                analysis_file_location[0])
            self._main_model.filter_results = self._main_model.object_data
            self.update_models_from_analysis_file()
            return (True, os.path.split(analysis_file_location[0])[-1])

        # if user cancelled loading dialog, skip indexing objects in main_view
        return (False, -1)
예제 #11
0
def saveMatrixAsImage():

    #Take picture of the grid
    matrixAsImage = matrixViewWrapper.gridWidget.grab()

    #Pop up "Save As" window to retrieve file name and type to save as
    nameAndType = QFileDialog.getSaveFileName(parent = im.mainWindow.centralwidget, caption = "Save Trial Matrix Capture As", filter = "PNG (*.png);;JPG (*.jpg)")

    #If user didn't click cancel on "Save As", save screenshot using "Save As" options
    if len(nameAndType[0]) > 0:
        matrixAsImage.save(nameAndType[0], im.extractFileType(nameAndType[1]))
예제 #12
0
	def loadOrderFile(self):
		"""Méthode qui permet de charger un fichier et afficher dans le plainText"""
		filename = QFileDialog.getOpenFileName(self, caption="Load the File", directory=os.getcwd(), filter="Text files (*.txt *.tab);;All (*.*)")
		if filename == "" and self.orderPathFile == "":
			self.displayError(error = "\"%s\" is not a valid file \n" % (filename))
		else:
			self.orderPathFile = filename
			self.workingDir = "/".join(str(filename).split("/")[:-1])+"/"
			self.basename = filename.split("/")[-1].split(".")[0]
			self.pathFileOut = self.workingDir+self.basename+"/"
			if os.path.isdir(self.pathFileOut):
				self.displayError(error = "Warnnig folder %s already exist,\nPlease remove/rename before run new analysis or use checkbox\n" % (self.pathFileOut))
			self.ui.orderPlainTextEdit.setPlainText(filename)
			self.actualizeRunBouton()
예제 #13
0
def export():
    #write to a text file
    savename = QFileDialog.getSaveFileName(caption="Export To...",
                                           filter="Text files (*.txt)")
    with open(savename[0], "w") as f:
        f.write(
            "Temperatures,xMin1,xMax1,StdDev1,FWHM1,Area1,Rsqr1,xMin2,xMax2,StdDev2,FWHM2,Area2,Rsqr2,Ratios\n"
        )
        for q in range(len(pltemps)):
            f.write(
                str(pltemps[q]) + "," + lowBound.text() + "," +
                highBound.text() + "," + str(stdev[q]) + "," + str(fwhm[q]) +
                "," + str(area[q]) + "," + str(rsqrd[q]) + ",")
            f.write(sLowBound.text() + "," + sHighBound.text() + "," +
                    str(sstdev[q]) + "," + str(sfwhm[q]) + "," +
                    str(sarea[q]) + "," + str(srsqrd[q]) + "," +
                    str(ratios[q]) + "\n")
예제 #14
0
 def loadOrderFile(self):
     """Méthode qui permet de charger un fichier et afficher dans le plainText"""
     filename = QFileDialog.getOpenFileName(
         self,
         caption="Load the File",
         directory=os.getcwd(),
         filter="Text files (*.txt *.tab);;All (*.*)")
     if filename == "" and self.orderPathFile == "":
         self.displayError(error="\"%s\" is not a valid file \n" %
                           (filename))
     else:
         self.orderPathFile = filename
         self.workingDir = "/".join(str(filename).split("/")[:-1]) + "/"
         self.basename = filename.split("/")[-1].split(".")[0]
         self.pathFileOut = self.workingDir + self.basename + "/"
         if os.path.isdir(self.pathFileOut):
             self.displayError(
                 error=
                 "Warnnig folder %s already exist,\nPlease remove/rename before run new analysis or use checkbox\n"
                 % (self.pathFileOut))
         self.ui.orderPlainTextEdit.setPlainText(filename)
         self.actualizeRunBouton()
예제 #15
0
    def saveDcm(self, event=None, filename=None):
        if self.dcm_3Ddata is not None:
            self.statusBar().showMessage('Saving DICOM data...')
            QApplication.processEvents()

            if filename is None:
                filename = str(QFileDialog.getSaveFileName(self, 'Save DCM file',
                                                           filter='Files (*.dcm)'))[0]
            if len(filename) > 0:
                savemat(filename, {'data': self.dcm_3Ddata,
                                   'voxelsize_mm': self.voxel_size_mm,
                                   'offsetmm': self.dcm_offsetmm},
                                   appendmat=False)

                self.setLabelText(self.text_dcm_out, filename)
                self.statusBar().showMessage('Ready')

            else:
                self.statusBar().showMessage('No output file specified!')

        else:
            self.statusBar().showMessage('No DICOM data!')
예제 #16
0
	def loadFolder(self,inputCat = None, methode = None):
		"""Méthode qui permet de charger un fichier et afficher dans le plainText"""
		directoryToOpen = os.getcwd()
		for key, folder in self.dicoFoldersCallibration.items():
			if folder != None:
				print(key, folder)
				directoryToOpen = folder
				break

		if methode == "clicked":
			pathdir = QFileDialog.getExistingDirectory(self, caption="Load the directory "+inputCat, directory=directoryToOpen)
			self.dicoObjectOpenLineEditCallibration[inputCat].setText(pathdir)
		elif methode == "write":
			pathdir = str(self.dicoObjectOpenLineEditCallibration[inputCat].text())

		if pathdir != "" and os.path.isdir(pathdir):
			self.dicoFoldersCallibration[inputCat] = pathdir
		else:
			self.dicoFoldersCallibration[inputCat] = ""
			self.dicoObjectOpenLineEditCallibration[inputCat].setText("")
			self.displayError(error = "\"%s\" is not a valid Path \n" % (pathdir))
		self.actualizeRunBouton()
		self.autocomplete_Folder()
예제 #17
0
 def _load_plugin_path(self):
     """Ask the user a plugin filename"""
     path = QFileDialog.getOpenFileName(self,
                                        translations.TR_SELECT_PLUGIN_PATH)
     if path:
         self._txtFilePath.setText(path)
예제 #18
0
 def select_output_dir(self):
     self.dirname = QFileDialog.getExistingDirectory(
         self.dlg, "Select directory ", "/home")
     self.dlg.lineEdit.setText(self.dirname)
예제 #19
0
 def select_output_file(self):
     self.dlg.lineEditFilename.clear()
     filename = QFileDialog.getSaveFileName(self.dlg, "Select output file ",
                                            "", '*.txt')
     self.dlg.lineEditFilename.setText(filename[0])
예제 #20
0
 def selectFile(self):
     filename, _filter = QFileDialog.getOpenFileName(
         None, "Open File", '..\\Firmware\\Hexa',
         "Arduino Sketch File (*.ino)")
     self.inoFilePath.setText(filename)
예제 #21
0
def fileBrowser():
    #Opens file browser to import data
    directory = QFileDialog.getExistingDirectory(
        parent=None, caption="Choose Data Directory")
    dirDisp.setText(directory)
    importData()