semvec/pypi-packages huggingface dataset:
sqladaptor 0.5.0
Starting adaptor for JSON/Pandas to SQL db
Requires Python: >=3.8

# sqladaptor

Transferring data, stored as JSON or Pandas, into an SQL database and back again.

## Why?

Building webserver prototypes, one often saves initial data as JSON or Pandas files.
Later, you will want to transition to an SQL database where
updating/inserting data to disk is more efficient. 

SqlAdaptor allows an easy transition for this transition, using a
familiar API consisting of dict lists and pandas dataframes. Table schema 
are treated as Json-Schema.

This is possible
because there is an equivalence between JSON dict lists, Pandas DataFrames
and SQL tables - they are all tabular arrangements of columnar data.

## Installation

```bash
pip install sqladaptor
```

## Basic Usage

Inserting dict lists into an SQLite db

```python
from sqladaptor.sqlite import SqliteAdaptor
import pandas

db = SqliteAdaptor('db.sqlite')
entries = [
    {"description": "this", "value": 1},
    {"description": "that", "value": 2}
]
db.set_from_df('data1', pandas.DataFrame(entries))
```

Read as dict lists or dataframes:
```python
entries = db.read_dicts('data1')
# [
#   {'description': 'this', 'value': 1}, 
#   {'description': 'that', 'value': 2}
# ]
df = db.read_df("data1", {"value": 2})
#   description  value
# 0        this      1
# 1        that      2
```

Get the table schema as Json-schema:
```python
schema = db.read_table_schema("data1")
# {
# │   'type': 'object',
# │   'properties': {
# │   │   'description': {'type': 'string'},
# │   │   'value': {'type': 'integer'}
# │   },
# │   'additionalProperties': False
# }
```

Make an SQL table with Json-schema:
```python
db.create_table(
    "data1",
    {
        "type": "object",
        "properties": {
            "row_id": {"type": "string"},
            "description": {"type": "string"},
            "value": {"type": "integer"},
        },
        "required": ["row_id"],
    },
)
```

Find using dict search:
```python
return_entries = db.read_dicts('data1', {"description": "this"})
# [{'description': 'this', 'value': 1}]
```

CRUD your database:
```python
db.insert("data1", {"value": 3, "description": "inserted"})
entries = db.read_dicts('data1')
# [
# │   {'description': 'this', 'value': 1},
# │   {'description': 'that', 'value': 2},
# │   {'description': 'inserted', 'value': 3}
# ]

db.update(
    "data1",
    {"description": "inserted"},
    {"description": "inserted-then-updated", "value": 77},
)
entries = db.read_dicts('data1')
# [
# │   {'description': 'this', 'value': 1},
# │   {'description': 'that', 'value': 2},
# │   {'description': 'inserted-then-updated', 'value': 77}
# ]

db.delete("data1", {"value": 77})
entries = db.read_dicts('data1')
# [{'description': 'this', 'value': 1}, {'description': 'that', 'value': 2}]
```
roiextract 0.0.3
Data-independent and data-driven optimization of spatial filters for extraction of ROI time series based on M/EEG
Requires Python: >=3.7

# ROIextract

Optimization of spatial filters for extraction of ROI time series based on the cross-talk function (CTF) or source reconstruction of spatial patterns (REC). **Work in progress!**

## Background

TODO

## Prerequisites

The toolbox is designed to be compatible with [MNE-Python]() as much as possible, and optimization only requires:

* `fwd: mne.Forward` - the description of the forward model
* `label: mne.Label` - the description of the region of interest (parcel/label)

## Parameters

There are several parameters of the optimization that need to be specified by the user:

* `lambda_` - this parameter allows fine-tuning the cross-talk function according to the demands of the analysis:
  * `lambda_ = 0` prioritizes the CTF ratio, leading to better localization of sources potential contributing to the extracted signal
  * `lambda_ = 1` prioritizes the CTF homogeneity, allowing to force contributions from the sources within the ROI to be more similar to a pre-specified template (see below)
  * values between 0 and 1 lead to a compromise between ratio and homogeneity
  * `lambda = auto` (experimental) - automatically selects the value of `lambda_` to obtain a fraction (controlled with `threshold`) of the maximal CTF ratio or homogeneity (controlled with `criteria`):
    * `threshold` - a number between 0 and 1 controlling the fraction
    * `criteria` - use either ratio (`criteria="ratio"`) or homogeneity (`criteria="homogeneity"`) for automatic suggestion of `lambda_`
* `template` - this parameter allows specifying the desired contributions of sources within ROIs, the following options are available:
  * `mean` - equal values for all sources (homogeneous contribution)
  * custom templates (e.g., gaussian) may be provided directly as an array of weights for all sources within the ROI

## Usage

Obtain a spatial filter that optimizes CTF properties:

```python
from roiextract import ctf_optimize_label

sf = ctf_optimize_label(fwd, label, template, lambda_)

sf, props = ctf_optimize_label(fwd, label, template, lambda_, quantify=True)

sf = ctf_optimize_label(fwd, label, template, lambda_='auto', threshold=0.95)
```

Plot the filter as a topomap:

```python
sf.plot(info)
```

Apply it to the data to obtain the time course of activity in the ROI/label:

```python
label_tc = sf.apply(data)
```

Estimate the CTF for the filter:

```python
ctf = sf.get_ctf_fwd(fwd)  # ctf is an instance of mne.SourceEstimate
```

Plot the CTF on the brain surface:

```python
ctf.plot()
```