pip install scistack # Installs tools for Python and MATLABSciStack is a suite of tools built by scientists for scientists of nearly any discipline to enhance data analysis pipelines. SciStack focuses on the common case of embarrassingly parallel workflows used to process nested datasets. It has three core goals:
- Minimalism: Minimize wasted time and effort, with a focus on reducing boilerplate code and offering advanced capabilities.
- Reusability: With a near-zero boilerplate format and support for cookie-cutter pipelines, SciStack pipelines are highly interoperable between projects. Thus, SciStack encourages scientific code reuse, an essential yet underutilized scientific work product.
- Openness: Minimize lock-in to the SciStack framework. SciStack code never touches scientific code, so you can easily change your data processing pipeline architecture at any time.
For any project, it's essential to pick the right tool for the job. SciStack - as the name implies - contains a suite of tools in a "stack" of increasing complexity and weight. There are three main tools in this stack:
scifor: The lightest-weight level. Syntactical sugar around nestedforloops. Operates on in-memory variables only (no file IO) just like standard functions.scidb: Wrapsscifor, adds a SQL database for data save/load and an auditable data processing historyscistackGUI: Wrapsscidb, adds a GUI to manage complex pipelines.
Imagine you are conducting a study of human subjects walking. Each Subject comes in to the lab for multiple Sessions, and in each Session they perform multiple Trials of walking. During each Trial, you measure their speed every 0.1 seconds and store that data to one .csv file for each trial.
import scifor
import pandas as pd
# Tell `scifor` about the structure of this dataset
scifor.set_schema(["subject", "session", "trial"]) # ordered one-to-many
def load_data(file_path: str) -> pd.DataFrame:
"""Example logic to load the data"""
return pd.read_csv(file_path)
path_template = scifor.PathInput("path/to/data/{subject}/{session}/{trial}.csv")
loaded_df = scifor.for_each(load_data,
file_path=path_template,
subject=[], session=[], trial=[],
output_names=["Loaded"]
)In this example step, after defining a basic load_data() function, we:
- Defined a
scifor.PathInput, providing a template to load all of the files of interest. - Invoked the main command
scifor.for_each(), providingload_dataas the function,file_pathas the input variable, and specifying to runload_dataonce over every combination ofsubject,session, andtrialthat match thescifor.PathInputpath template. loaded_dfis apd.DataFramewith one row persubject,session, andtrialcombination. The data is stored into the"Loaded"field specified in the optionaloutput_namesparameter (default output name:"value").
import numpy as np
def process_data(speed: np.ndarray) -> np.ndarray:
"""Square every data point"""
return np.square(speed)
squared_df = scifor.for_each(process_data,
speed=loaded_df,
subject=[], session=[], trial=[]
)scifor.for_each automatically parses loaded_df, repeatedly inputting only the speed values for one combination of subject, session, trial, allowing process_data() to remain very simple and ignore the structure of this project's dataset.
To see more, refer to the scifor docs.