Skip to content

Commit

Permalink
Merge pull request #143 from asiaszmek/add_github_actions
Browse files Browse the repository at this point in the history
Add GitHub actions
  • Loading branch information
abukaj authored Aug 4, 2023
2 parents de7fd0c + 2a02ecc commit 2e5f8f4
Show file tree
Hide file tree
Showing 58 changed files with 90 additions and 212 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Python package

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
build:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]


steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest
46 changes: 0 additions & 46 deletions .travis.yml

This file was deleted.

120 changes: 0 additions & 120 deletions continuous_integration/install.sh

This file was deleted.

Empty file removed continuous_integration/readme
Empty file.
20 changes: 0 additions & 20 deletions continuous_integration/test_script.sh

This file was deleted.

6 changes: 3 additions & 3 deletions figures/kCSD_properties/tutorial_basic_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def make_plots(fig_title,
t_max = np.max(np.abs(true_csd))
levels = np.linspace(-1*t_max, t_max, 16)
ind_interest = np.mgrid[0:t_csd_z.shape[2]:np.complex(0,z_steps+2)]
ind_interest = np.array(ind_interest, dtype=np.int)[1:-1]
ind_interest = np.array(ind_interest, dtype=int)[1:-1]
for ii, idx in enumerate(ind_interest):
ax = plt.subplot(gs[ii, 0])
im = plt.contourf(t_csd_x[:,:,idx], t_csd_y[:,:,idx], true_csd[:,:,idx],
Expand Down Expand Up @@ -131,7 +131,7 @@ def make_plots(fig_title,
t_max = np.max(np.abs(pre_cv[:,:,:,0]))
levels_kcsd = np.linspace(-1*t_max, t_max, 16)
ind_interest = np.mgrid[0:k_csd_z.shape[2]:np.complex(0,z_steps+2)]
ind_interest = np.array(ind_interest, dtype=np.int)[1:-1]
ind_interest = np.array(ind_interest, dtype=int)[1:-1]
for ii, idx in enumerate(ind_interest):
ax = plt.subplot(gs[ii, 2])
im = plt.contourf(k_csd_x[:,:,idx], k_csd_y[:,:,idx], pre_cv[:,:,idx,0],
Expand Down Expand Up @@ -159,7 +159,7 @@ def make_plots(fig_title,
t_max = np.max(np.abs(est_csd[:,:,:,0]))
levels_kcsd = np.linspace(-1*t_max, t_max, 16)
ind_interest = np.mgrid[0:k_csd_z.shape[2]:np.complex(0,z_steps+2)]
ind_interest = np.array(ind_interest, dtype=np.int)[1:-1]
ind_interest = np.array(ind_interest, dtype=int)[1:-1]
for ii, idx in enumerate(ind_interest):
ax = plt.subplot(gs[ii, 3])
im = plt.contourf(k_csd_x[:,:,idx], k_csd_y[:,:,idx], est_csd[:,:,idx,0],
Expand Down
6 changes: 4 additions & 2 deletions figures/npx/Neuropixels_with_fitted_dipoles_model.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from pathlib import Path
import kCSD2D_reconstruction_from_npx as npx
import matplotlib.pyplot as plt
import matplotlib.cm as cm
import scipy
import numpy as np
from numpy.linalg import LinAlgError
from scipy.signal import filtfilt, butter

import DemoReadSGLXData.readSGLX as readSGLX

def set_axis(ax, x, y, letter=None):
ax.text(
Expand Down Expand Up @@ -198,4 +200,4 @@ def gauss2d(x, y, p):
make_plot(ax4, k.estm_x, k.estm_y, projection.reshape(true_csd.shape), ele_pos,
title='Projection', cmap='bwr')
plt.tight_layout()
plt.savefig('Neuropixels_with_fitted_model.png', dpi=300)
plt.savefig('Neuropixels_with_fitted_model.png', dpi=300)
2 changes: 1 addition & 1 deletion figures/npx/dan_kCSD_from_npx.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def dan_fetch_electrodes(meta):
def eles_to_rows(eles):
rows = []
for ele in eles:
rows.append(np.int(np.ceil(ele/2)))
rows.append(int(np.ceil(ele/2)))
return rows

def eles_to_ycoord(eles):
Expand Down
2 changes: 1 addition & 1 deletion figures/npx/map_npx_ele.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
def eles_to_rows(eles):
rows = []
for ele in eles:
rows.append(np.int(np.ceil(ele/2)))
rows.append(int(np.ceil(ele/2)))
return rows

def eles_to_ycoord(eles):
Expand Down
2 changes: 1 addition & 1 deletion figures/npx/map_npx_ele_Daniel.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
def eles_to_rows(eles):
rows = []
for ele in eles:
rows.append(np.int(np.ceil(ele/2)))
rows.append(int(np.ceil(ele/2)))
return rows

def eles_to_ycoord(eles):
Expand Down
3 changes: 2 additions & 1 deletion figures/sKCSD_paper/make_fig_5.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@
utils.save_sim(path, ker)
est_skcsd = ker.values(estimate='CSD')
except NameError:
skcsd, pot, cell_obj = utils.load_sim(path)
skcsd, pot, morphology, ele_pos, n_src = utils.load_sim(path)
cell_obj = sKCSDcell(morphology, ele_pos, n_src)
est_skcsd = cell_itself[i].transform_to_3D(skcsd)

xmin = cell_itself[i].xmin
Expand Down
7 changes: 4 additions & 3 deletions figures/sKCSD_paper/make_fig_9.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import sys
import os
from kcsd import sKCSD, sKCSDcell
from kcsd import sKCSD_utils as utils
from kcsd import sKCSD_utils as utils
import kcsd.validation.plotting_functions as pl
import sKCSD_utils
import numpy.random
Expand Down Expand Up @@ -87,17 +87,18 @@
L1 = []

for i, nl in enumerate(noise_levels):
new_LFP = data.LFP
if nl:
noise = numpy.random.normal(scale=std/nl, size=shape)
snr = np.round((new_LFP.var()**.5/noise.var()**.5))

else:
noise = 0
snr = 0

new_LFP += noise
snrs.append(snr)

new_LFP = data.LFP + noise




Expand Down
2 changes: 1 addition & 1 deletion kcsd/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os
kcsd_loc = os.path.dirname(os.path.abspath(__file__))
sample_data_path = os.path.join(kcsd_loc, '..', 'data')
sample_data_path = os.path.join(kcsd_loc, 'data')

from .KCSD import KCSD1D, KCSD2D, KCSD3D, MoIKCSD, oKCSD1D, oKCSD2D, oKCSD3D
from .sKCSD import sKCSD, sKCSDcell
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 5 additions & 3 deletions kcsd/sKCSD.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,8 @@ def points_in_between(self, p1, p0, last):
# bresenhamline only works with 2D vectors with coordinates
if p1[0] == p0[0] and p1[1] == p0[1] and p1[2] == p0[2]:
return [np.array(p1)]
new_p1, new_p0 = np.ndarray((1, 3), dtype=np.int), np.ndarray((1, 3), dtype=np.int)
new_p1, new_p0 = np.ndarray((1, 3), dtype=int), np.ndarray((1, 3),
dtype=int)
for i in range(3):
new_p1[0, i], new_p0[0, i] = p1[i], p0[i]
intermediate_points = utils.bresenhamline(new_p0, new_p1, -1)
Expand Down Expand Up @@ -337,7 +338,7 @@ def get_grid(self):
[self.ymin, self.ymax],
[self.zmin, self.zmax]
]
dims = np.ones((3, ), dtype=np.int)
dims = np.ones((3, ), dtype=int)
for i, dx in enumerate(self.dxs):
dims[i] = 1
if dx:
Expand Down Expand Up @@ -365,7 +366,7 @@ def point_coordinates(self, morpho, dxs=None):
minis = np.array([self.xmin, self.ymin, self.zmin])
zero_coords = np.zeros((3, ), dtype=int)
coor_3D = np.zeros((morpho.shape[0] - 1, morpho.shape[1]),
dtype=np.int)
dtype=int)
if dxs is None:
dxs = self.dxs
for i, dx in enumerate(dxs):
Expand Down Expand Up @@ -634,6 +635,7 @@ def parameters(self, **kwargs):
self.dim = 'skCSD'
self.tolerance = kwargs.pop('tolerance', 2e-06)
self.exact = kwargs.pop('exact', False)
self.est_xyz_auto = False
if kwargs:
raise TypeError('Invalid keyword arguments:', kwargs.keys())

Expand Down
2 changes: 1 addition & 1 deletion kcsd/sKCSD_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def load_sim(path):
morphology = np.array(cell_data['morphology'])
ele_pos = np.array(cell_data['ele_pos'])
n_src = cell_data['n_src']
return est_csd, est_pot, cell_obj, morphology, ele_pos, n_src
return est_csd, est_pot, morphology, ele_pos, n_src


def load_elpos(path):
Expand Down
Loading

0 comments on commit 2e5f8f4

Please sign in to comment.