Skip to content

Commit

Permalink
Next release in pyproject
Browse files Browse the repository at this point in the history
  • Loading branch information
alejoe91 committed Nov 3, 2023
2 parents b288d23 + b8b5918 commit e893406
Show file tree
Hide file tree
Showing 26 changed files with 589 additions and 165 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 23.10.0
rev: 23.10.1
hooks:
- id: black
files: ^src/
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Please [Star](https://github.com/SpikeInterface/probeinterface/stargazers) the p

ProbeInterface aims to provide a common framework to handle probe information across neuroscience experiments.

ProbeInterface is used by the [SpikeInterface](https://github.com/SpikeInterface/spikeinterface) package to attach a probe information to a recordng object.
ProbeInterface is used by the [SpikeInterface](https://github.com/SpikeInterface/spikeinterface) package to attach probe information to a recording object.
You can find detailed documentation in the [SpikeInterface documentation](https://spikeinterface.readthedocs.io/en/latest/modules/core.html#handling-probes).

In practice, ProbeInterface is a lightweight package to handle:
Expand Down
2 changes: 1 addition & 1 deletion doc/generate_format_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
print(d.keys())

fig, ax = plt.subplots(figsize=(8, 8))
plot_probe(probe, with_channel_index=True, ax=ax)
plot_probe(probe, ax=ax)
ax.set_xlim(-50, 200)
ax.set_ylim(-150, 120)

Expand Down
1 change: 1 addition & 0 deletions doc/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Release notes
.. toctree::
:maxdepth: 1

releases/0.2.19.rst
releases/0.2.18.rst
releases/0.2.17.rst
releases/0.2.16.rst
Expand Down
3 changes: 3 additions & 0 deletions doc/releases/0.2.18.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ Features

* Extend probe constructor (name, serial_number, manufacturer, model_name) (#206)
* Extend available NP2 probe types to commercial types (20** series) (#217)
* Remove :code:`with_channel_index` argument from :code:`plot_probe` (#229)
* Remove checker for unique contact ids in probe group (#229)
* Unify usage of "contact" and remove "channel" notation (except for "device_channel_index") (#229)


Bug fixes
Expand Down
10 changes: 10 additions & 0 deletions doc/releases/0.2.19.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
probeinterface 0.2.19
---------------------

Nov, 2nd 2023


Features
^^^^^^^^

* Unify NP reading with probe part number (#232)
4 changes: 2 additions & 2 deletions examples/ex_03_generate_probe_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

print('probe0.get_contact_count()', probe0.get_contact_count())
print('probe1.get_contact_count()', probe1.get_contact_count())
print('probegroup.get_channel_count()', probegroup.get_channel_count())
print('probegroup.get_contact_count()', probegroup.get_contact_count())

##############################################################################
#  We can now plot all probes in the same axis:
Expand All @@ -44,6 +44,6 @@
##############################################################################
#  or in separate axes:

plot_probe_group(probegroup, same_axes=False, with_channel_index=True)
plot_probe_group(probegroup, same_axes=False, with_contact_id=True)

plt.show()
6 changes: 3 additions & 3 deletions examples/ex_05_device_channel_indices.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
xpitch=75, ypitch=75, y_shift_per_column=[0, -37.5, 0],
contact_shapes='circle', contact_shape_params={'radius': 12})

plot_probe(probe, with_channel_index=True)
plot_probe(probe, with_contact_id=True)

##############################################################################
# The Probe is not connected to any device yet:
Expand All @@ -51,7 +51,7 @@
# * the prbXX is the contact index ordered from 0 to N
# * the devXX is the channel index on the device (with the second half reversed)

plot_probe(probe, with_channel_index=True, with_device_index=True)
plot_probe(probe, with_contact_id=True, with_device_index=True)

##############################################################################
# Very often we have several probes on the device and this can lead to even
Expand Down Expand Up @@ -85,6 +85,6 @@
# The indices of the probe group can also be plotted:

fig, ax = plt.subplots()
plot_probe_group(probegroup, with_channel_index=True, same_axes=True, ax=ax)
plot_probe_group(probegroup, with_contact_id=True, same_axes=True, ax=ax)

plt.show()
2 changes: 1 addition & 1 deletion examples/ex_06_import_export_to_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,6 @@
f.write(prb_two_tetrodes)

two_tetrode = read_prb('two_tetrodes.prb')
plot_probe_group(two_tetrode, same_axes=False, with_channel_index=True)
plot_probe_group(two_tetrode, same_axes=False, with_contact_id=True)

plt.show()
6 changes: 3 additions & 3 deletions examples/ex_07_probe_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
df = probegroup.to_dataframe()
df

plot_probe_group(probegroup, with_channel_index=True, same_axes=True)
plot_probe_group(probegroup, with_contact_id=True, same_axes=True)

##############################################################################
# Generate a linear probe:
Expand All @@ -44,7 +44,7 @@
from probeinterface import generate_linear_probe

linear_probe = generate_linear_probe(num_elec=16, ypitch=20)
plot_probe(linear_probe, with_channel_index=True)
plot_probe(linear_probe, with_contact_id=True)

##############################################################################
# Generate a multi-column probe:
Expand All @@ -57,7 +57,7 @@
xpitch=22, ypitch=20,
y_shift_per_column=[0, -10, 0],
contact_shapes='square', contact_shape_params={'width': 12})
plot_probe(multi_columns, with_channel_index=True, )
plot_probe(multi_columns, with_contact_id=True, )

##############################################################################
# Generate a square probe:
Expand Down
2 changes: 1 addition & 1 deletion examples/ex_10_get_probe_from_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
# When plotting, the channel indices are automatically displayed with
# one-based notation (even if internally everything is still zero based):

plot_probe(probe, with_channel_index=True)
plot_probe(probe, with_contact_id=True)

##############################################################################

Expand Down
2 changes: 1 addition & 1 deletion examples/ex_11_automatic_wiring.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
# * the lower "devXX" is the channel on the Intan device (zero-based)

fig, ax = plt.subplots(figsize=(5, 15))
plot_probe(probe, with_channel_index=True, with_device_index=True, ax=ax)
plot_probe(probe, with_contact_id=True, with_device_index=True, ax=ax)


plt.show()
Expand Down
75 changes: 62 additions & 13 deletions resources/generate_cambridgeneurotech_libray.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
2023-06-14
generate new library
2023-10-30
Generate new library with some fixes
Derive probes to be used with SpikeInterface base on Cambridgeneurotech databases
Probe library to match and add on
https://gin.g-node.org/spikeinterface/probeinterface_library/src/master/cambridgeneurotech
Expand All @@ -36,16 +40,26 @@

from pathlib import Path

import json
import shutil


# work_dir = r"C:\Users\Windows\Dropbox (Scripps Research)\2021-01-SpikeInterface_CambridgeNeurotech"
# work_dir = '.'
# work_dir = '/home/samuel/Documents/SpikeInterface/2021-03-01-probeinterface_CambridgeNeurotech/'
# work_dir = '/home/samuel/Documents/SpikeInterface/2022-05-20-probeinterface_CambridgeNeurotech/'
# work_dir = '/home/samuel/Documents/SpikeInterface/2022-10-18-probeinterface_CambridgeNeurotech/'
work_dir = '/home/samuel/OwnCloudCNRS/probeinterface/2023-06-14-probeinterface-CambridgeNeurotech/'
# work_dir = '/home/samuel/OwnCloudCNRS/probeinterface/2023-06-14-probeinterface-CambridgeNeurotech/'
work_dir = '/home/samuel/OwnCloudCNRS/probeinterface/2023-10-30-probeinterface-CambridgeNeurotech/'


library_folder = '/home/samuel/Documents/SpikeInterface/probeinterface_library/cambridgeneurotech/'

library_folder = Path(library_folder)

work_dir = Path(work_dir).absolute()

export_folder = work_dir / 'export_2023_06_14'
export_folder = work_dir / 'export_2023_10_30'
probe_map_file = work_dir / 'ProbeMaps_Final2023.xlsx'
probe_info_table_file = work_dir / 'ProbesDataBase_Final2023.csv'

Expand Down Expand Up @@ -74,7 +88,7 @@ def convert_contact_shape(listCoord):
listCoord = [float(s) for s in listCoord.split(' ')]
return listCoord

def get_channel_index(connector, probe_type):
def get_contact_order(connector, probe_type):
"""
Get the channel index given a connector and a probe_type.
This will help to re-order the probe contact later on.
Expand Down Expand Up @@ -179,7 +193,7 @@ def create_CN_figure(probe_name, probe):
plot_probe(probe, ax=ax,
contacts_colors = ['#5bc5f2'] * n, # made change to default color
probe_shape_kwargs = dict(facecolor='#6f6f6e', edgecolor='k', lw=0.5, alpha=0.3), # made change to default color
with_channel_index=True)
with_contact_id=True)

ax.set_xlabel(u'Width (\u03bcm)') #modif to legend
ax.set_ylabel(u'Height (\u03bcm)') #modif to legend
Expand Down Expand Up @@ -244,22 +258,57 @@ def generate_all_probes():
#~ continue
print(' ', probe_name)

channelIndex = get_channel_index(connector = connector, probe_type = probe_info['part'])
contact_order = get_contact_order(connector = connector, probe_type = probe_info['part'])

order = np.argsort(channelIndex)
probe = probe_unordered.get_slice(order)
sorted_indices = np.argsort(contact_order)
probe = probe_unordered.get_slice(sorted_indices)

probe.annotate(name=probe_name,
manufacturer='cambridgeneurotech',
first_index=1)
probe.annotate(name=probe_name, manufacturer='cambridgeneurotech')

# one based in cambridge neurotech
contact_ids = np.arange(order.size) + 1
contact_ids =contact_ids.astype(str)
contact_ids = np.arange(sorted_indices.size) + 1
contact_ids = contact_ids.astype(str)
probe.set_contact_ids(contact_ids)

export_one_probe(probe_name, probe)


def synchronize_library():

for source_probe_file in export_folder.glob('**/*.json'):
# print()
print(source_probe_file.stem)
target_probe_file = library_folder / source_probe_file.parent.stem / source_probe_file.name
# print(target_probe_file)
with open(source_probe_file, mode='r')as source:
source_dict = json.load(source)

with open(target_probe_file, mode='r')as target:
target_dict = json.load(target)

source_dict.pop('version')

target_dict.pop('version')

# this was needed between version 0.2.17 > 0.2.18
# target_dict["probes"][0]["annotations"].pop("first_index")

same = source_dict == target_dict

# copy the json
shutil.copyfile(source_probe_file, target_probe_file)
if not same:
# copy the png
shutil.copyfile(source_probe_file.parent / (source_probe_file.stem + '.png'),
target_probe_file.parent / (target_probe_file.stem + '.png') )






# library_folder

if __name__ == '__main__':
generate_all_probes()
# generate_all_probes()
synchronize_library()
1 change: 1 addition & 0 deletions src/probeinterface/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ def generate_multi_columns_probe(
probe = Probe(ndim=2, si_units="um")
probe.set_contacts(positions=positions, shapes=contact_shapes, shape_params=contact_shape_params)
probe.create_auto_shape(probe_type="tip", margin=25)
probe.set_contact_ids(np.arange(positions.shape[0]).astype("str"))

return probe

Expand Down
Loading

0 comments on commit e893406

Please sign in to comment.