Create A Batch¶
Goal¶
Import one or more FLASH/ImageJ experiment folders into a processed Batch
that can be plotted, pipelined, exported, and saved.
Use this workflow when your data is still in experiment-folder form. If you
already have a clean table, use from_dataframe
instead.
Inputs¶
- A parent folder containing experiment subfolders, or a dictionary that maps experiment names to folder paths.
- A built
groupListfromGroupBuilder. - A
batch_pathoutput folder. - Optional
pickle_pathfor cache files. - Optional image-import choice. Use
import_images=Falsefor faster summary-only analysis.
Minimal Path¶
from PyFLASH import GroupBuilder, create_batch
groups = (
GroupBuilder("Diagnosis")
.add("Control", short="Control", color="grey")
.add("AD", short="AD", color="red")
.compare("Control", "AD")
.build()
)
batch = create_batch(
"SCN_Diagnosis",
groups,
batch_path=r"C:\path\to\analysis-output",
experiments=r"C:\path\to\experiment-parent",
pickle_path=r"C:\path\to\pickles",
)
Full Workflow¶
- Check the experiment folder layout. PyFLASH accepts current FLASH folders and supported legacy layouts when they contain importable tables.
- Build groups before import. The group short names should match the values
PyFLASH will see in the data, such as
Control,MCI, orAD. - Choose explicit output folders. Keep
batch_pathfor analysis outputs andpickle_pathfor reusable.pklcache files. - Run
create_batch. If a matching pickle already exists andrerun=False, PyFLASH returns the cached object instead of reprocessing. - Inspect the loaded object before plotting:
print(batch.name)
print(batch.summary.shape)
print(batch.fig_path)
print(batch.export_path)
print([group.name for group in batch.condition_list])
- Force a rebuild when source data or group definitions changed:
batch = create_batch(
"SCN_Diagnosis",
groups,
batch_path=r"C:\path\to\analysis-output",
experiments=r"C:\path\to\experiment-parent",
pickle_path=r"C:\path\to\pickles",
rerun=True,
)
- Save time on table-only work by skipping image discovery:
batch = create_batch(
"SCN_Diagnosis",
groups,
batch_path=r"C:\path\to\analysis-output",
experiments=r"C:\path\to\experiment-parent",
import_images=False,
)
Outputs¶
create_batch returns a Batch in Python. The object contains summary,
summaries, condition_list, data, fig_path, data_path, and
export_path.
When pickle_path is provided, PyFLASH writes or reuses:
The returned batch also records standard output roots below batch_path, such
as Results/Python Figures, Results/Data and Stats, Results/Separate CSVs,
and Exports. Those folders may be created lazily when plots or exports run.
Troubleshooting¶
No experiment folders found: pass the parent folder that contains experiment subfolders, or pass a dictionary of explicit experiment paths.- Cached results look stale: run with
rerun=True. - Image workflows have no images: rebuild with
import_images=True, or use the UI/image workflows to inspect image-table availability. - Group labels do not match: check the values in
batch.summary["Condition"]and the factor columns created by the group list. - A moved cache loads but output paths are wrong: use load and rebase a pickle.