Comments (14)
@jrliu95 re group labels, I think those are the common ones. I believe 'minigrid' was also used in some cases (not sure the distinction). What do you think about including 'other' just in the rare case we have something else?
from ecogvis.
I really liked the most recent version of the HTK loading with the dialog box. On the point of electrode information, can there be an optional field to give the path to the electrode anatomical information? That way, if the user does have access to this information, the electrodes table can be populated.
I can give you a function that parses the elecs file, if that would help (it's largely co-opted from Ben's original code)
from ecogvis.
@jrliu95 definitely, I'd say that's the last missing thing over there.
We received a sample from Kristin yesterday and I'll work on that next!
from ecogvis.
Ah, gotcha! Awesome
from ecogvis.
@jrliu95 would be helpful to take a look at the electrodes file parsing code!
from ecogvis.
Here's the function we use:
def elecs_to_electrode_table(nwb_file, elecspath):
"""
Takes an NWB file and the elecs .mat file path, loads the anatomical and
location information for each electrode,
and writes this information to the NWB file.
Parameters:
-----------
nwbfile : object
An NWB file object.
elecspath : str
Path to the TDT_elecs_all.mat file for this subject. First, second,
and third columns of the key 'elecmatrix'
should be x, y, and z coordinates, respectively. For the 'anatomy'
field, second column should be the full electrode label and the
fourth column should be the anatomical location name.
Returns:
--------
nwb_file : object
The edited NWB file with the added electrode information.
ecog_channels : 1d array of ints
Indices of electrodes channels that were not labeled NaN.
"""
# Get anatomical and location information for electrodes.
elec_mat = sio.loadmat(elecspath)
labels = elec_mat['anatomy'][:, 1]
location = elec_mat['anatomy'][:, 3]
x = elec_mat['elecmatrix'][:, 0]
y = elec_mat['elecmatrix'][:, 1]
z = elec_mat['elecmatrix'][:, 2]
# Get MNI warped electrode coordinates.
try:
elec_mat_warped = sio.loadmat(elecspath.split('.')[0] + '_warped.mat')
x_warped = elec_mat_warped['elecmatrix'][:, 0]
y_warped = elec_mat_warped['elecmatrix'][:, 1]
z_warped = elec_mat_warped['elecmatrix'][:, 2]
except FileNotFoundError:
print('No warped electrode information found...filling with zeros.')
x_warped = np.zeros_like(x)
y_warped = np.zeros_like(y)
z_warped = np.zeros_like(z)
# Define electrode device label names.
group_labels = []
for current_group in labels:
group_labels.append(current_group[0].rstrip('0123456789'))
# Get the list of unique electrode device label names
unique_group_indexes = np.unique(group_labels, return_index=True)[1]
unique_group_labels = [group_labels[f] for f in
sorted(unique_group_indexes)]
# Add additional columns to the electodes table.
nwb_file.add_electrode_column('label', 'label of electrode')
nwb_file.add_electrode_column('bad', 'electrode identified as too noisy')
nwb_file.add_electrode_column('x_warped',
'x warped onto cvs_avg35_inMNI152')
nwb_file.add_electrode_column('y_warped',
'y warped onto cvs_avg35_inMNI152')
nwb_file.add_electrode_column('z_warped',
'z warped onto cvs_avg35_inMNI152')
for group_label in unique_group_labels:
if group_label != 'NaN':
# Get region name and device label for the group.
if 'Depth' in group_label:
group_label_split = group_label.split('Depth')
elif 'Strip' in group_label:
group_label_split = group_label.split('Strip')
elif 'Grid' in group_label:
group_label_split = group_label.split('Grid')
elif 'Pole' in group_label:
group_label_split = group_label.split('Pole')
# Get general group region
brain_area = group_label_split[0]
# Create electrode device (same as the group).
device = nwb_file.create_device(group_label)
# Create electrode group with name, description, device object,
# and general location.
electrode_group = nwb_file.create_electrode_group(
name='{} electrodes'.format(group_label),
description='{}'.format(group_label),
device=device,
location=str(brain_area))
# Loop through the number of electrodes in this electrode group
elec_nums = np.where(np.array(group_labels) == group_label)[0]
for elec_num in elec_nums:
# Add the electrode information to the table.
elec_location = location[elec_num]
if len(elec_location) == 0:
# If no label is recorded for this electrode, set it to
# nan.
elec_location = 'nan'
else:
elec_location = elec_location[0]
nwb_file.add_electrode(
x=x[elec_num],
y=y[elec_num],
z=z[elec_num],
imp=np.nan,
x_warped=x_warped[elec_num],
y_warped=y_warped[elec_num],
z_warped=z_warped[elec_num],
location=str(elec_location),
filtering='filtering',
group=electrode_group,
label=str(labels[elec_num][0]),
bad=False)
# Get the electrodes that were recorded into the file.
ecog_channels = np.where(np.array(group_labels) != 'NaN')[0]
# # Create electrode table region that includes all the recorded
# electrodes.
# all_table_region = nwb_file.create_electrode_table_region(
# list(range(len(ecog_channels))), 'all electrodes')
return nwb_file, ecog_channels
I think the labeling of some elecs as nan
is separate from our discussion of null
electrodes.
from ecogvis.
To clarify, the nan
entries in the elecs file are ignored here. The variable ecog_channels
is created for this purpose, and used later to take only the channels that had real entries in the elecs file.
Going forward, I think we want to include every recorded channel (whether it's connected to a real brain electrode or not) and make a null
entry for it in the electrodes table.
from ecogvis.
@jrliu95
c01039c is using your code, with some changes to grab the null
electrodes in between valid electrodes and other small things (such as brain_area for HeschlsGyrus)
from ecogvis.
-
Can we change this column name to
null
since the value is a boolean anyways.is_null
just seems weird to me but not sure if others feel different.
-
@kristinksellers Do these cover all the group labels? I guess we might need to ask Ben Speidel about these, to make sure all possible options are parsed correctly.
ecogVIS/ecogvis/functions/tdt_to_nwb/chang2nwb.py
Lines 522 to 523 in 2765c28
from ecogvis.
With respect to null
vs is_null
, I do like when there is some kind of naming convention for boolean-valued variables/columns. So I like is_null
, as long as we're using is_
for all boolean columns. Are there other columns (even in other tables) that have bools in them, and if so, what are their names?
from ecogvis.
That is true, but if the column is boolean valued, this can be described in the definition of the table column. The other boolean column is bad
which is default False for everything unless marked in the GUI, which I think is written directly into the table.
from ecogvis.
Ah well let's be consistent with bad
then.
from ecogvis.
@jrliu95 re group labels, I think those are the common ones. I believe 'minigrid' was also used in some cases (not sure the distinction). What do you think about including 'other' just in the rare case we have something else?
@kristinksellers sounds good to me, will include the 'other' option
@jrliu95 @emilyps14 about columns names, whatever you decide is good, just let me know what sounds better for your use and I change it
from ecogvis.
Yep, other
sounds good to me!
@luiztauffer Yeah, I think we decided to be consistent with how the existing boolean column is named (bad
) and change is_null
to null
.
from ecogvis.
Related Issues (20)
- test_processing_data doesn't test preprocessing HOT 1
- add Hierarchical Behavioral Data view
- Remove misleading messages
- Spectral decomposition and high gamma duplicate code and processing
- Unnecessary package? HOT 1
- Packages missing from setup.py
- error when not selecting file HOT 1
- update survey to include nans HOT 2
- Running spectral decomposition twice crashes GUI HOT 1
- How to load HTK data? HOT 2
- feature request: write gridOrient file HOT 3
- Take out the check for 'speaker1' or 'speaker2' when opening the Audio Event Detection gui
- loading error HOT 1
- HierarchicalBehavioralTable is dropped by nwb_copy_file
- Save file name not the same as load file name
- Error after loading the processed file
- Upgrade to pynwb>=2.0.0
- Load different acquisitions
- Option to delete/remove/overwrite (CV Event) intervals HOT 2
- Notch filtering operates on the channels dimension rather than the time dimension HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ecogvis.