Another issue with PhySortingExtractor
Hi,

we enocunter anothe issue with PhySortingExtractor.
Once we run the extractor after curation in Phy we noticed the following:

"get_unit_ids" in spikeinterface is giving us the  index of the units shown in "si_unit_id" of the ClusterView (Phy GUI).
However, the spike trains information are stored under the index "id" of the ClusterView (Phy GUI). 
Since the "id" and the "si_unit_id" of the ClusterView (Phy GUI) often do not match (especially after merging or splitting during manual curation), this creates issues when extracting the timestamps of the spikes (and even the waveforms) when using "get_unit_ids" to iterate through the id of the unit after manual curation.

I hope this is clear, otherwise I am happy to give more details.
diff --git a/spikeinterface/extractors/phykilosortextractors.py b/spikeinterface/extractors/phykilosortextractors.py
index 865ce9a0..2106ac7d 100644
--- a/spikeinterface/extractors/phykilosortextractors.py
+++ b/spikeinterface/extractors/phykilosortextractors.py
@@ -96,6 +96,26 @@ class BasePhyKilosortSortingExtractor(BaseSorting):
 
         if 'si_unit_id' in cluster_info.columns:
             unit_ids = cluster_info["si_unit_id"].values
+
+            if np.all(np.isnan(unit_ids)):
+                max_si_unit_id = -1
+            else:
+                max_si_unit_id = int(np.nanmax(unit_ids))
+
+            # update spike cluster values
+            spike_clusters_new = np.zeros_like(spike_clusters)
+            for i, (phy_id, si_id) in enumerate(zip(cluster_info["cluster_id"].values,
+                                                    cluster_info["si_unit_id"].values)):
+                if np.isnan(si_id):
+                    max_si_unit_id += 1
+                    new_si_id = int(max_si_unit_id)
+                else:
+                    new_si_id = si_id
+                unit_ids[i] = new_si_id
+
+                spike_clusters_new[spike_clusters == phy_id] = new_si_id
+            unit_ids = unit_ids.astype(int)
+            spike_clusters = spike_clusters_new
             del cluster_info["si_unit_id"]
         else:
             unit_ids = cluster_info["cluster_id"].values
['spikeinterface/extractors/phykilosortextractors.py']