Esempio n. 1
0
    def set_parameters(self):
        settings = self.settings_box.settings
        advanced_options = self.settings_box.advanced_options

        self.data_path = settings.pop('data_file_path')
        self.working_directory = settings.pop('working_directory')
        self.results_directory = settings.pop('results_directory')
        self.probe_layout = settings.pop('probe_layout')
        self.time_range = settings.pop('time_range')
        self.num_channels = settings.pop('num_channels')

        params = KilosortParams()
        params = params.parse_obj(advanced_options)
        params = params.parse_obj(settings)

        assert params

        self.params = params

        self.settings_box.disable_all_buttons()
        QtWidgets.QApplication.setOverrideCursor(QtGui.QCursor(QtCore.Qt.WaitCursor))

        self.prepare_for_new_context()
        self.load_raw_data()
        self.setup_context()
        self.setup_probe_view()
        self.setup_data_view()
        self.update_run_box()

        self.settings_box.reenable_all_buttons()
        QtWidgets.QApplication.restoreOverrideCursor()
Esempio n. 2
0
    def get_default_advanced_options(self):
        advanced_options_path = self.gui.local_config_path / "advanced_options.json"
        default_advanced_options_path = self.gui.local_config_path / "default_advanced_options.json"

        if advanced_options_path.exists():
            with open(advanced_options_path, "r") as advanced_options_file:
                advanced_options = json.load(advanced_options_file)

        elif default_advanced_options_path.exists():
            with open(default_advanced_options_path,
                      "r") as default_advanced_options_file:
                advanced_options = json.load(default_advanced_options_file)

        else:
            advanced_options = KilosortParams().dict()

            with open(default_advanced_options_path,
                      "w+") as default_advanced_options_file:
                advanced_options_dump = json.dumps(advanced_options)
                default_advanced_options_file.write(advanced_options_dump)

        return advanced_options
Esempio n. 3
0
    def setup(self):
        self.setTitle("Settings")

        layout = QtWidgets.QVBoxLayout()

        font = self.load_settings_button.font()
        font.setPointSize(20)
        self.load_settings_button.setFont(font)
        self.load_settings_button.setDisabled(True)
        self.load_settings_button.clicked.connect(self.update_settings)

        select_data_file_layout = QtWidgets.QHBoxLayout()
        select_data_file_layout.addWidget(self.select_data_file, 70)
        select_data_file_layout.addWidget(self.data_file_path_input, 30)
        self.select_data_file.clicked.connect(self.on_select_data_file_clicked)
        self.data_file_path_input.textChanged.connect(
            self.on_data_file_path_changed)
        self.data_file_path_input.editingFinished.connect(
            self.on_data_file_path_changed)

        select_working_directory_layout = QtWidgets.QHBoxLayout()
        select_working_directory_layout.addWidget(
            self.select_working_directory, 70)
        select_working_directory_layout.addWidget(self.working_directory_input,
                                                  30)
        self.select_working_directory.clicked.connect(
            self.on_select_working_dir_clicked)
        self.working_directory_input.textChanged.connect(
            self.on_working_directory_changed)
        self.working_directory_input.editingFinished.connect(
            self.on_working_directory_changed)

        select_results_directory_layout = QtWidgets.QHBoxLayout()
        select_results_directory_layout.addWidget(
            self.select_results_directory, 70)
        select_results_directory_layout.addWidget(self.results_directory_input,
                                                  30)
        self.select_results_directory.clicked.connect(
            self.on_select_results_dir_clicked)
        self.results_directory_input.textChanged.connect(
            self.on_results_directory_changed)
        self.results_directory_input.editingFinished.connect(
            self.on_results_directory_changed)

        probe_layout_layout = QtWidgets.QHBoxLayout()
        probe_layout_layout.addWidget(self.probe_layout_text, 70)
        probe_layout_layout.addWidget(self.probe_layout_selector, 30)
        self.probe_layout_selector.setSizeAdjustPolicy(
            QtWidgets.QComboBox.AdjustToMinimumContentsLength)
        self.probe_layout_selector.currentTextChanged.connect(
            self.on_probe_layout_selected)

        probe_preview_layout = QtWidgets.QHBoxLayout()
        self.probe_preview_button.setDisabled(True)
        self.probe_preview_button.clicked.connect(self.show_probe_layout)
        probe_preview_layout.addWidget(self.probe_preview_button,
                                       30,
                                       alignment=QtCore.Qt.AlignRight)

        num_channels_layout = QtWidgets.QHBoxLayout()
        num_channels_layout.addWidget(self.num_channels_text, 70)
        num_channels_layout.addWidget(self.num_channels_input, 30)
        self.num_channels_input.textChanged.connect(
            self.on_number_of_channels_changed)

        time_range_layout = QtWidgets.QHBoxLayout()
        time_range_layout.addWidget(self.time_range_text, 70)
        time_range_layout.addWidget(self.time_range_min_input, 15)
        time_range_layout.addWidget(self.time_range_max_input, 15)
        self.time_range_min_input.textChanged.connect(
            self.on_time_range_changed)
        self.time_range_max_input.textChanged.connect(
            self.on_time_range_changed)

        min_firing_rate_layout = QtWidgets.QHBoxLayout()
        min_firing_rate_layout.addWidget(self.min_firing_rate_text, 70)
        min_firing_rate_layout.addWidget(self.min_firing_rate_input, 30)
        self.min_firing_rate_input.textChanged.connect(
            self.on_min_firing_rate_changed)

        threshold_layout = QtWidgets.QHBoxLayout()
        threshold_layout.addWidget(self.threshold_text, 70)
        threshold_layout.addWidget(self.threshold_lower_input, 15)
        threshold_layout.addWidget(self.threshold_upper_input, 15)
        self.threshold_upper_input.textChanged.connect(
            self.on_thresholds_changed)
        self.threshold_lower_input.textChanged.connect(
            self.on_thresholds_changed)

        lambda_layout = QtWidgets.QHBoxLayout()
        lambda_layout.addWidget(self.lambda_text, 70)
        lambda_layout.addWidget(self.lambda_value_input, 30)
        self.lambda_value_input.textChanged.connect(self.on_lambda_changed)

        auc_splits_layout = QtWidgets.QHBoxLayout()
        auc_splits_layout.addWidget(self.auc_splits_text, 70)
        auc_splits_layout.addWidget(self.auc_splits_input, 30)
        self.auc_splits_input.textChanged.connect(self.on_auc_splits_changed)

        self.advanced_options_button.clicked.connect(
            self.on_advanced_options_clicked)

        layout.addWidget(self.load_settings_button)
        layout.addLayout(select_data_file_layout)
        layout.addLayout(select_working_directory_layout)
        layout.addLayout(select_results_directory_layout)
        layout.addLayout(probe_layout_layout)
        layout.addLayout(probe_preview_layout)
        layout.addLayout(num_channels_layout)
        layout.addLayout(time_range_layout)
        layout.addLayout(min_firing_rate_layout)
        layout.addLayout(threshold_layout)
        layout.addLayout(auc_splits_layout)
        layout.addWidget(self.advanced_options_button)

        self.setLayout(layout)

        self.set_default_field_values(KilosortParams().parse_obj(
            self.advanced_options))

        self.update_settings()
Esempio n. 4
0
    def setup(self):
        self.setTitle("Settings")

        layout = QtWidgets.QGridLayout()

        font = self.load_settings_button.font()
        font.setPointSize(18)
        self.load_settings_button.setFont(font)
        self.load_settings_button.setDisabled(True)
        self.load_settings_button.clicked.connect(self.update_settings)
        layout.addWidget(self.load_settings_button, 0, 0, 1, 5)

        layout.addWidget(self.select_data_file, 1, 0, 1, 3)
        layout.addWidget(self.data_file_path_input, 1, 3, 1, 2)
        self.select_data_file.clicked.connect(self.on_select_data_file_clicked)
        self.data_file_path_input.textChanged.connect(
            self.on_data_file_path_changed)
        self.data_file_path_input.editingFinished.connect(
            self.on_data_file_path_changed)

        layout.addWidget(self.select_working_directory, 2, 0, 1, 3)
        layout.addWidget(self.working_directory_input, 2, 3, 1, 2)
        self.select_working_directory.clicked.connect(
            self.on_select_working_dir_clicked)
        self.working_directory_input.textChanged.connect(
            self.on_working_directory_changed)
        self.working_directory_input.editingFinished.connect(
            self.on_working_directory_changed)

        layout.addWidget(self.select_results_directory, 3, 0, 1, 3)
        layout.addWidget(self.results_directory_input, 3, 3, 1, 2)
        self.select_results_directory.clicked.connect(
            self.on_select_results_dir_clicked)
        self.results_directory_input.textChanged.connect(
            self.on_results_directory_changed)
        self.results_directory_input.editingFinished.connect(
            self.on_results_directory_changed)

        layout.addWidget(self.probe_layout_text, 4, 0, 1, 3)
        layout.addWidget(self.probe_layout_selector, 4, 3, 1, 2)
        self.probe_layout_selector.setSizeAdjustPolicy(
            QtWidgets.QComboBox.AdjustToMinimumContentsLength)
        self.probe_layout_selector.currentTextChanged.connect(
            self.on_probe_layout_selected)

        self.probe_preview_button.setDisabled(True)
        self.probe_preview_button.clicked.connect(self.show_probe_layout)
        layout.addWidget(self.probe_preview_button, 5, 3, 1, 2)

        layout.addWidget(self.num_channels_text, 6, 0, 1, 3)
        layout.addWidget(self.num_channels_input, 6, 3, 1, 2)
        self.num_channels_input.textChanged.connect(
            self.on_number_of_channels_changed)

        layout.addWidget(self.time_range_text, 7, 0, 1, 3)
        layout.addWidget(self.time_range_min_input, 7, 3, 1, 1)
        layout.addWidget(self.time_range_max_input, 7, 4, 1, 1)
        self.time_range_min_input.textChanged.connect(
            self.on_time_range_changed)
        self.time_range_max_input.textChanged.connect(
            self.on_time_range_changed)

        layout.addWidget(self.min_firing_rate_text, 8, 0, 1, 3)
        layout.addWidget(self.min_firing_rate_input, 8, 3, 1, 2)
        self.min_firing_rate_input.textChanged.connect(
            self.on_min_firing_rate_changed)

        layout.addWidget(self.threshold_text, 9, 0, 1, 3)
        layout.addWidget(self.threshold_lower_input, 9, 3, 1, 1)
        layout.addWidget(self.threshold_upper_input, 9, 4, 1, 1)
        self.threshold_upper_input.textChanged.connect(
            self.on_thresholds_changed)
        self.threshold_lower_input.textChanged.connect(
            self.on_thresholds_changed)

        layout.addWidget(self.lambda_text, 10, 0, 1, 3)
        layout.addWidget(self.lambda_value_input, 10, 3, 1, 2)
        self.lambda_value_input.textChanged.connect(self.on_lambda_changed)

        layout.addWidget(self.auc_splits_text, 11, 0, 1, 3)
        layout.addWidget(self.auc_splits_input, 11, 3, 1, 2)
        self.auc_splits_input.textChanged.connect(self.on_auc_splits_changed)

        self.advanced_options_button.clicked.connect(
            self.on_advanced_options_clicked)

        layout.addWidget(self.advanced_options_button, 12, 0, 1, 5)

        self.setLayout(layout)

        self.set_default_field_values(KilosortParams().parse_obj(
            self.advanced_options))

        self.update_settings()