ibl_alignment_gui.loaders.alignment_uploader

Classes

AlignmentUploader

Abstract base class for saving alignment results.

AlignmentUploaderLocal

Alignment uploader using local file system.

AlignmentUploaderOne

Alignment uploader using ONE.

class ibl_alignment_gui.loaders.alignment_uploader.AlignmentUploader(brain_atlas)[source]

Bases: ABC

Abstract base class for saving alignment results.

Subclasses must implement the abstract upload_data method.

Parameters:

brain_atlas (AllenAtlas) – An AllenAtlas instance

abstractmethod upload_data(*args, **kwargs)[source]

Upload alignment data.

Return type:

str

class ibl_alignment_gui.loaders.alignment_uploader.AlignmentUploaderLocal(data_path, shank_idx, n_shanks, brain_atlas, user=None)[source]

Bases: AlignmentUploader

Alignment uploader using local file system.

xyz channels and alignments are saved to json files.

For single-shank data, save filenames:
  • channel_locations.json

  • prev_alignments.json

For multi-shank data, expected filenames:
  • channel_locations_shank<N>.json

  • prev_alignments_shank<N>.json

Parameters:
  • data_path (Path) – The path to the local data folder.

  • shank_idx (int) – Index of the shank (0-based).

  • n_shanks (int) – Total number of shanks.

  • brain_atlas (AllenAtlas) – An AllenAtlas instance

  • user (str or None) – Username for tagging alignments.

get_brain_regions(data)[source]

Get brain regions for each channel based on xyz coordinates.

Parameters:

data (dict) – Alignment and channel data.

Returns:

brain_regions – Information about location of electrode channels in brain atlas

Return type:

dict

get_channels(brain_regions)[source]

Create channel dictionary in form to write to json file.

Parameters:

brain_regions (dict) – Information about location of electrode channels in brain atlas

Returns:

channels – Dictionary of dictionaries containing data for each channel

Return type:

dict[str, dict]

save_alignments(alignments)[source]

Save alignments to local json file.

Parameters:

alignments (dict[str, Any]) – Dictionary of alignment data.

Return type:

None

save_channels(channels)[source]

Save channel locations to local json file.

Parameters:

channels (dict[str, dict]) – Dictionary of dictionaries containing data for each channel

Return type:

None

upload_alignments(data)[source]

Update and save alignments to local json file.

Parameters:

data (dict) – Alignment and channel data.

Return type:

None

upload_channels(data)[source]

Get channel locations and save to local json file.

Parameters:

data (dict) – Alignment and channel data.

Return type:

None

upload_data(data, shank_sites=None)[source]

Save channels and alignments to local files.

Parameters:
  • data (dict) – Alignment and channel data.

  • shank_sites (Bunch) – A Bunch object containing the channels that correspond to the shank

Returns:

Message containing information about upload result.

Return type:

str

Notes

This method sets the following attributes:

self.orig_idxnp.ndarray

The original index of the channel in the raw data

class ibl_alignment_gui.loaders.alignment_uploader.AlignmentUploaderOne(insertion, one, brain_atlas)[source]

Bases: AlignmentUploader

Alignment uploader using ONE. xyz channels and alignments are saved to Alyx database.

Parameters:
  • insertion (dict) – Probe insertion information.

  • one (ONE) – An ONE instance used to upload results to Alyx

  • brain_atlas (AllenAtlas) – An AllenAtlas object.

get_upload_info(channels, resolved)[source]

Return an info message based on upload result.

Parameters:
  • channels (bool) – Whether channels were uploaded.

  • resolved (bool) – Where the alignment is resolved.

Returns:

Status message.

Return type:

str

save_alignments(alignments)[source]

Save updated alignments to Alyx.

Parameters:

alignments (dict) – Updated alignments.

Return type:

None

set_user_qc(align_qc, ephys_qc, ephys_desc, force_resolve)[source]

Set QC and confidence strings, optionally launching critical reasons GUI.

Parameters:
  • align_qc (str) – Alignment confidence.

  • ephys_qc (str) – Ephys QC.

  • ephys_desc (list of str) – Description of QC issues.

  • force_resolve (bool) – Whether to force the alignment to be resolved.

Return type:

None

upload_alignments(data)[source]

Upload alignment data to Alyx.

Parameters:

data (dict) – A dict containing data for upload.

Returns:

alignments – Updated alignments dictionary.

Return type:

dict

upload_channels(data)[source]

Upload channel locations to Alyx if not resolved.

Parameters:

data (dict) – A dict containing data for upload.

Returns:

True if channels uploaded, False otherwise.

Return type:

bool

upload_data(data, **kwargs)[source]

Upload channels, alignments, and QC to Alyx.

Parameters:

data (dict) – Alignment and channel data.

Returns:

Message containing information about upload result.

Return type:

str

upload_qc(data, alignments)[source]

Compute alignment qc and upload evaluation to Alyx.

Parameters:
  • data (dict) – Data required to run alignment qc.

  • alignments (dict) – Dictionary of alignments on which to compute the qc.

Returns:

self.resolved – Alignment resolved bool

Return type:

bool