Skip to content

Commit

Permalink
tetrode compatibility
Browse files Browse the repository at this point in the history
incluye compatibilidad con tetrodos
  • Loading branch information
labcnUC committed Oct 24, 2024
1 parent 0383697 commit 85d61ba
Show file tree
Hide file tree
Showing 8 changed files with 2,424 additions and 993 deletions.
549 changes: 519 additions & 30 deletions .ipynb_checkpoints/sorterpipeline-checkpoint.ipynb

Large diffs are not rendered by default.

Binary file modified __pycache__/preprocessing_functions.cpython-312.pyc
Binary file not shown.
28 changes: 16 additions & 12 deletions preprocessing_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ def read_rhd(rhd_folder):
print("No se encontraron archivos .rhd en la carpeta.")
return None
else:
print(f"Leyendo {rhd_files}")
recordings = [read_intan(file, stream_name='RHD2000 amplifier channel') for file in rhd_files]
recordings = [read_intan(file, stream_name='RHD2000 amplifier channel') for file in rhd_files]

if len(recordings) > 1:
recording = si.concatenate_recordings(recordings)
Expand Down Expand Up @@ -58,22 +57,25 @@ def get_recording(excel_file, probegroup_file):

if recording is None:
continue

list_triggers, ms_before, ms_after = process_artifacts(row.artifacts, row.data_folder, fs)

recording = prep.bandpass_filter(recording, freq_min=500., freq_max=9000.)
recording = recording.set_probegroup(probegroup, group_mode='by_probe')
recording = prep.remove_artifacts(
recording=recording,
list_triggers=list_triggers,
mode="zeros"
)
if len(list_triggers) > 0:
recording = prep.remove_artifacts(
recording=recording,
list_triggers=list_triggers,
mode="zeros"
)

recordings.append(recording)

if len(recordings) > 1:
final_recording = si.concatenate_recordings(recordings)
print(f"Concatenados {len(recordings)} registros.")
print("Concatenados los siguientes registros:")
for i, rec in enumerate(recordings, 1):
print(f"Registro {i}: {rec}")
elif recordings:
final_recording = recordings[0]
print("Solo un registro disponible para concatenar.")
Expand Down Expand Up @@ -107,8 +109,10 @@ def process_artifacts(artifacts, base_folder, fs):
lan_file = [lan_file for lan_file in all_files if lan_file.startswith('LAN') and lan_file.endswith('500.mat')]

if not lan_file:
raise FileNotFoundError("No se encontró ningún archivo LAN en el directorio especificado.")

print("No se encontró ningún archivo LAN en el directorio especificado.")
print("\033[31mSe omite la remoción de artefactos\033[0m")
return [], [], [] # Retornar listas vacías y continuar

path_lan = os.path.join(base_folder, lan_file[0])
print (path_lan)
# Leer el archivo HDF5
Expand Down Expand Up @@ -148,7 +152,7 @@ def process_artifacts(artifacts, base_folder, fs):

# Tiempos antes y después del artefacto
ms_before = 0 # zero before trigger
ms_after = 500 # 500 ms after trigger
ms_after = 500 # 500 ms after trigger <- punto para cambiar los segmentos que componen el artefacto.

return list_triggers, ms_before, ms_after

Expand Down
53 changes: 5 additions & 48 deletions probes/Probegenerator_v3.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"id": "60bb2672-04d5-49af-9aa7-339e1bae64dd",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -221,63 +221,20 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"id": "81956b71-7635-4fd0-961d-3fe3d6e9adb6",
"metadata": {},
"outputs": [
{
"ename": "ModuleNotFoundError",
"evalue": "No module named 'kilosort'",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)",
"Input \u001b[1;32mIn [1]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mkilosort\u001b[39;00m\n",
"\u001b[1;31mModuleNotFoundError\u001b[0m: No module named 'kilosort'"
]
}
],
"outputs": [],
"source": [
"import kilosort"
]
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"id": "9e025135-8285-46eb-927a-3d82b251564a",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Requirement already satisfied: kilosort in c:\\users\\germa\\anaconda3\\envs\\spikeinterface\\lib\\site-packages (4.0.13)\n",
"Requirement already satisfied: numpy<2.0.0,>=1.20.0 in c:\\users\\germa\\anaconda3\\envs\\spikeinterface\\lib\\site-packages (from kilosort) (1.26.4)\n",
"Requirement already satisfied: scipy in c:\\users\\germa\\anaconda3\\envs\\spikeinterface\\lib\\site-packages (from kilosort) (1.14.0)\n",
"Requirement already satisfied: scikit-learn in c:\\users\\germa\\anaconda3\\envs\\spikeinterface\\lib\\site-packages (from kilosort) (1.5.0)\n",
"Requirement already satisfied: tqdm in c:\\users\\germa\\anaconda3\\envs\\spikeinterface\\lib\\site-packages (from kilosort) (4.66.4)\n",
"Requirement already satisfied: torch>=1.6 in c:\\users\\germa\\anaconda3\\envs\\spikeinterface\\lib\\site-packages (from kilosort) (2.3.1)\n",
"Requirement already satisfied: numba in c:\\users\\germa\\anaconda3\\envs\\spikeinterface\\lib\\site-packages (from kilosort) (0.60.0)\n",
"Requirement already satisfied: faiss-cpu in c:\\users\\germa\\anaconda3\\envs\\spikeinterface\\lib\\site-packages (from kilosort) (1.8.0.post1)\n",
"Requirement already satisfied: filelock in c:\\users\\germa\\anaconda3\\envs\\spikeinterface\\lib\\site-packages (from torch>=1.6->kilosort) (3.13.1)\n",
"Requirement already satisfied: typing-extensions>=4.8.0 in c:\\users\\germa\\anaconda3\\envs\\spikeinterface\\lib\\site-packages (from torch>=1.6->kilosort) (4.11.0)\n",
"Requirement already satisfied: sympy in c:\\users\\germa\\anaconda3\\envs\\spikeinterface\\lib\\site-packages (from torch>=1.6->kilosort) (1.12.1)\n",
"Requirement already satisfied: networkx in c:\\users\\germa\\anaconda3\\envs\\spikeinterface\\lib\\site-packages (from torch>=1.6->kilosort) (3.2.1)\n",
"Requirement already satisfied: jinja2 in c:\\users\\germa\\anaconda3\\envs\\spikeinterface\\lib\\site-packages (from torch>=1.6->kilosort) (3.1.4)\n",
"Requirement already satisfied: fsspec in c:\\users\\germa\\anaconda3\\envs\\spikeinterface\\lib\\site-packages (from torch>=1.6->kilosort) (2024.6.1)\n",
"Requirement already satisfied: mkl<=2021.4.0,>=2021.1.1 in c:\\users\\germa\\anaconda3\\envs\\spikeinterface\\lib\\site-packages (from torch>=1.6->kilosort) (2021.4.0)\n",
"Requirement already satisfied: packaging in c:\\users\\germa\\anaconda3\\envs\\spikeinterface\\lib\\site-packages (from faiss-cpu->kilosort) (24.1)\n",
"Requirement already satisfied: llvmlite<0.44,>=0.43.0dev0 in c:\\users\\germa\\anaconda3\\envs\\spikeinterface\\lib\\site-packages (from numba->kilosort) (0.43.0)\n",
"Requirement already satisfied: joblib>=1.2.0 in c:\\users\\germa\\anaconda3\\envs\\spikeinterface\\lib\\site-packages (from scikit-learn->kilosort) (1.4.2)\n",
"Requirement already satisfied: threadpoolctl>=3.1.0 in c:\\users\\germa\\anaconda3\\envs\\spikeinterface\\lib\\site-packages (from scikit-learn->kilosort) (3.5.0)\n",
"Requirement already satisfied: colorama in c:\\users\\germa\\anaconda3\\envs\\spikeinterface\\lib\\site-packages (from tqdm->kilosort) (0.4.6)\n",
"Requirement already satisfied: intel-openmp==2021.* in c:\\users\\germa\\anaconda3\\envs\\spikeinterface\\lib\\site-packages (from mkl<=2021.4.0,>=2021.1.1->torch>=1.6->kilosort) (2021.4.0)\n",
"Requirement already satisfied: tbb==2021.* in c:\\users\\germa\\anaconda3\\envs\\spikeinterface\\lib\\site-packages (from mkl<=2021.4.0,>=2021.1.1->torch>=1.6->kilosort) (2021.13.0)\n",
"Requirement already satisfied: MarkupSafe>=2.0 in c:\\users\\germa\\anaconda3\\envs\\spikeinterface\\lib\\site-packages (from jinja2->torch>=1.6->kilosort) (2.1.3)\n",
"Requirement already satisfied: mpmath<1.4.0,>=1.1.0 in c:\\users\\germa\\anaconda3\\envs\\spikeinterface\\lib\\site-packages (from sympy->torch>=1.6->kilosort) (1.3.0)\n"
]
}
],
"outputs": [],
"source": [
"!pip install kilosort"
]
Expand Down
Loading

0 comments on commit 85d61ba

Please sign in to comment.