dbscan widget calls postprocessing dbscan and saves dbscan, dbcluster and yaml file
@@ -35,7 +35,7 @@ from sklearn.metrics.pairwise import euclidean_distances
from sklearn.cluster import KMeans
from mpl_toolkits.mplot3d import axes3d
from collections import Counter
-
+from h5py import File
from tqdm import tqdm
import colorsys
@@ -1170,7 +1170,7 @@ class DbscanDialog(QtWidgets.QDialog):
self.radius.setRange(0, 1e6)
self.radius.setValue(1)
grid.addWidget(self.radius, 0, 1)
- grid.addWidget(QtWidgets.QLabel("Density:"), 1, 0)
+ grid.addWidget(QtWidgets.QLabel("Min. density:"), 1, 0)
self.density = QtWidgets.QDoubleSpinBox()
self.density.setRange(0, 1e6)
self.density.setValue(4)
@@ -1210,7 +1210,7 @@ class HdbscanDialog(QtWidgets.QDialog):
self.min_samples = QtWidgets.QDoubleSpinBox()
self.min_samples.setRange(0, 1e6)
self.min_samples.setValue(10)
- grid.addWidget(self.radius, 0, 1)
+ grid.addWidget(self.min_samples, 0, 1)
grid.addWidget(QtWidgets.QLabel("Min. cluster size:"), 1, 0)
self.min_cluster = QtWidgets.QDoubleSpinBox()
self.min_cluster.setRange(0, 1e6)
@@ -2756,15 +2756,27 @@ class View(QtWidgets.QLabel):
self.update_scene()
def dbscan(self):
- radius, density, ok = DbscanDialog.getParams()
+ radius, min_density, ok = DbscanDialog.getParams()
if ok:
- print("Hurray")
- # postprocessing -> dbscan(locs, radius, min_density)
+ print("Hurray_DBSCAN")
+
+ for locs, locs_path, locs_info in zip(self.locs, self.locs_paths, self.infos):
+ clusters, locs = postprocess.dbscan(locs, radius, min_density)
+ base, ext = os.path.splitext(locs_path)
+ dbscan_info = {
+ "Generated by": "Picasso DBSCAN",
+ "Radius": radius,
+ "Minimum local density": min_density,
+ }
+ locs_info.append(dbscan_info)
+ io.save_locs(base + "_dbscan.hdf5", locs, locs_info)
+ with File(base + "_dbclusters.hdf5", "w") as clusters_file:
+ clusters_file.create_dataset("clusters", data=clusters)
def hdbscan(self):
min_samples, min_cluster, ok = HdbscanDialog.getParams()
if ok:
- print("Hurray")
+ print("Hurray_HDBSCAN")
def shifts_from_picked_coordinate(self, locs, coordinate):
"""
@@ -6055,7 +6067,7 @@ class Window(QtWidgets.QMainWindow):
dbscan_action.triggered.connect(self.view.dbscan)
hdbscan_action = postprocess_menu.addAction("HDBSCAN")
- dbscan_action.triggered.connect(self.view.hdbscan)
+ hdbscan_action.triggered.connect(self.view.hdbscan)
self.load_user_settings()
