From 13fce81fe58891642f4a233f0a56a698abb68b1c Mon Sep 17 00:00:00 2001 From: Guillaume Viejo Date: Tue, 4 Feb 2025 10:28:39 -0500 Subject: [PATCH] Removing template_loader.py --- template_loader.py | 115 --------------------------------------------- 1 file changed, 115 deletions(-) delete mode 100644 template_loader.py diff --git a/template_loader.py b/template_loader.py deleted file mode 100644 index 4b2e56f1..00000000 --- a/template_loader.py +++ /dev/null @@ -1,115 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Template for building a data loader with pynapple -""" -# @Author: gviejo -# @Date: 2022-01-26 18:13:42 -# @Last Modified by: gviejo -# @Last Modified time: 2022-08-18 18:02:38 - -import os - -from pynwb import NWBHDF5IO - -from pynapple.io.loader import BaseLoader - - -class MyCustomIO(BaseLoader): - def __init__(self, path): - """ - - Parameters - ---------- - path : str - The path to the data. - """ - self.basename = os.path.basename(path) - - super().__init__(path) - - # Need to check if nwb file exists and if data are there - loading_my_data = True - if self.path is not None: - nwb_path = os.path.join(self.path, "pynapplenwb") - if os.path.exists(nwb_path): - files = os.listdir(nwb_path) - if len([f for f in files if f.endswith(".nwb")]): - success = self.load_my_nwb(path) - if success: - loading_my_data = False - - # Bypass if data have already been transfered to nwb - if loading_my_data: - self.load_my_data(path) - - self.save_my_data_in_nwb(path) - - def load_my_data(self, path): - """ - This load the raw data - - Parameters - ---------- - path : str - Path to the session - """ - """ - Load Raw data here - """ - print(path) - return None - - def save_my_data_in_nwb(self, path): - """ - Save the raw data to NWB - - Parameters - ---------- - path : TYPE - Description - """ - self.nwb_path = os.path.join(path, "pynapplenwb") - if not os.path.exists(self.nwb_path): - raise RuntimeError("Path {} does not exist.".format(self.nwb_path)) - self.nwbfilename = [f for f in os.listdir(self.nwb_path) if "nwb" in f][0] - self.nwbfilepath = os.path.join(self.nwb_path, self.nwbfilename) - - io = NWBHDF5IO(self.nwbfilepath, "r+") - - """ - Save data in NWB here - """ - - io.close() - - return - - def load_my_nwb(self, path): - """ - This load the nwb that is already create by the base loader - - Parameters - ---------- - path : str - Path to the session - """ - self.nwb_path = os.path.join(path, "pynapplenwb") - if not os.path.exists(self.nwb_path): - raise RuntimeError("Path {} does not exist.".format(self.nwb_path)) - self.nwbfilename = [f for f in os.listdir(self.nwb_path) if "nwb" in f][0] - self.nwbfilepath = os.path.join(self.nwb_path, self.nwbfilename) - - io = NWBHDF5IO(self.nwbfilepath, "r") - nwbfile = io.read() - print(nwbfile) - - """ - Add code to write to nwb file here - """ - - io.close() - - -mydata = MyCustomIO(".") - -print(type(mydata))