Skip to content

Commit

Permalink
Merge pull request #96 from int-brain-lab/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
mayofaulkner authored Jun 14, 2023
2 parents 27301bb + bde9a6e commit 0ec4cb3
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 9 deletions.
2 changes: 1 addition & 1 deletion atlaselectrophysiology/load_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ def upload_dj(self, align_qc, ephys_qc, ephys_desc):
if ephys_qc.upper() == 'CRITICAL':
usrpmt.main_gui(eid=self.probe_id, reasons_selected=ephys_desc, one=self.one)

def update_qc(self, upload_alyx=True, upload_flatiron=True):
def update_qc(self, upload_alyx=True, upload_flatiron=False):
# if resolved just update the alignment_number
align_qc = AlignmentQC(self.probe_id, one=self.one, brain_atlas=self.brain_atlas,
collection=self.probe_collection)
Expand Down
53 changes: 45 additions & 8 deletions ephysfeatures/features_across_region.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
import copy
from pathlib import Path
import sys

import pyqtgraph as pg
from PyQt5 import QtCore, QtGui, QtWidgets
import sys
import pandas as pd
import numpy as np

from ibllib.atlas import AllenAtlas
import atlaselectrophysiology.ColorBar as cb
from ibllib.pipes.ephys_alignment import EphysAlignment
from atlaselectrophysiology.AdaptedAxisItem import replace_axis
from ephysfeatures.qrangeslider import QRangeSlider
import copy
from one.remote import aws
from one.api import ONE
from pathlib import Path


pg.setConfigOption('background', 'w')
pg.setConfigOption('foreground', 'k')
Expand Down Expand Up @@ -49,10 +54,15 @@ def __init__(self, one, region_ids=None, ba=None, download=True, size=(1600, 800
self.ba = ba or AllenAtlas()
br = self.ba.regions

table_path = self.one.cache_dir.joinpath('bwm_features')
table_path = self.one.cache_dir.joinpath('bwm_features') #TODO NOTE THIS FOLDER DOES NOT EXIST ON S3
if download:
s3, bucket_name = aws.get_s3_from_alyx(alyx=self.one.alyx)
aws.s3_download_folder("aggregates/bwm/latest", table_path, s3=s3, bucket_name=bucket_name)
# Download file
base_path = Path("aggregates/atlas") # TODO THIS FOLDER DOES NOT CONTAIN PROBES
file_list = ['channels.pqt', 'probes.pqt', 'raw_ephys_features.pqt']
for file_name in file_list:
aws.s3_download_file(base_path.joinpath(file_name), table_path.joinpath(file_name),
s3=s3, bucket_name=bucket_name)

channels = pd.read_parquet(table_path.joinpath('channels.pqt'))
probes = pd.read_parquet(table_path.joinpath('probes.pqt'))
Expand All @@ -71,16 +81,36 @@ def __init__(self, one, region_ids=None, ba=None, download=True, size=(1600, 800
self.data = pd.merge(data, depths, left_on=['pid', 'axial_um'], right_on=['pid', 'depths'], how='outer')
self.data.loc[self.data['histology'] == 'alf', 'histology'] = 'resolved'

del data, depths, channels, probes, features, df_voltage

# Initialise region combobox
if region_ids is not None:
self.region_ids = region_ids
else:
self.region_ids = self.data.atlas_id.unique()
# self.region_ids = self.data.atlas_id.unique()

# Get the unique region IDs appearing in the data as int64
ids = np.sort(data.atlas_id.dropna().astype(np.int64).unique())
# Find the region indices within the BrainAtlas, to keep the atlas order.
indata = np.isin(br.id, ids)
self.region_ids = br.id[indata]

del data, depths, channels, probes, features, df_voltage

acronyms = br.id2acronym(self.region_ids)
level = br.level[indata]

# Show hierarchy
acro_h = [((' ' * level) + acro) for (level, acro) in zip(level, acronyms)]

for id, acro in enumerate(acronyms):
# NOTE: this does not work well as is because of the hierarchy spaces at the beginning
# of the strings. You can't type "FRP" but need to type " FRP" which is impractical!

# # Completion.
# completer = QtWidgets.QCompleter(acro_h, self)
# completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive)
# completer.setCompletionMode(QtWidgets.QCompleter.PopupCompletion)
# self.region_combobox.setCompleter(completer)

for id, acro in enumerate(acro_h):
item = QtGui.QStandardItem(id)
item.setText(acro)
item.setEditable(False)
Expand Down Expand Up @@ -120,6 +150,13 @@ def layout(self, size):
options_widget.setLayout(options_layout)

region_combobox = QtWidgets.QComboBox()

# NOTE: uncomment if users may want to type the acronym with autocompletion
# but that does not work well at the moment because of the spaces prefix (to show
# hierarchical information).
# region_combobox.setEditable(True)

self.region_combobox = region_combobox
self.region_list = QtGui.QStandardItemModel()
region_combobox.setModel(self.region_list)
region_combobox.activated.connect(self.on_region_chosen)
Expand Down

0 comments on commit 0ec4cb3

Please sign in to comment.