use std::path::Path;
use crate::io::phy::PhyFolder;
use crate::io::{nwb::NwbUnitsTable, sorting_zarr::SortingZarr};
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum SortingFormat {
Phy,
SortingZarr,
NwbUnits,
}
impl SortingFormat {
pub fn from_path_name(path: &Path) -> Self {
let name = path.to_string_lossy();
if name.ends_with(".nwb.zarr") {
Self::NwbUnits
} else if name.ends_with(".zarr") {
Self::SortingZarr
} else {
Self::Phy
}
}
}
pub fn detect_sorting(path: &Path) -> SortingFormat {
if PhyFolder::is_phy_folder(path) {
return SortingFormat::Phy;
}
{
if NwbUnitsTable::is_units_table(path) {
return SortingFormat::NwbUnits;
}
if SortingZarr::is_sorting_zarr(path) {
return SortingFormat::SortingZarr;
}
}
SortingFormat::from_path_name(path)
}