diff options
| author | Sam Scholten | 2025-10-23 16:05:39 +1000 |
|---|---|---|
| committer | Sam Scholten | 2025-10-23 16:05:39 +1000 |
| commit | a74c1249a18dbb4d6a69f52ac88a7bb8f6ac0eb7 (patch) | |
| tree | d686e561b69d1aae5105cdb9905889dd6ca2b388 | |
| parent | d671e06c561337ca5a82fd9aa78a3cb089e90efc (diff) | |
| download | transivent-2.0.2.tar.gz transivent-2.0.2.zip | |
Fix examples to use correct API importsv2.0.2
- example.py: Update to use detect_from_wfm() instead of process_file()
- example_diffusion.py: Import diffusion functions from event_processor submodule
- Both examples now correctly use the v2.0.0 API structure
| -rw-r--r-- | examples/example.py | 14 | ||||
| -rw-r--r-- | examples/example_diffusion.py | 20 |
2 files changed, 19 insertions, 15 deletions
diff --git a/examples/example.py b/examples/example.py index 06c33c5..0c79986 100644 --- a/examples/example.py +++ b/examples/example.py @@ -2,7 +2,7 @@ from warnings import warn import matplotlib as mpl -from transivent import configure_logging, get_waveform_params, process_file +from transivent import configure_logging, detect_from_wfm, get_waveform_params # --- User configuration dictionary --- CONFIG = { @@ -72,8 +72,8 @@ def main() -> None: ) sampling_interval = params["sampling_interval"] - # Call with explicit parameters - process_file( + # Call with explicit parameters using new API + results = detect_from_wfm( name=name, sampling_interval=sampling_interval, data_path=merged_config["DATA_PATH"], @@ -88,12 +88,16 @@ def main() -> None: envelope_mode_limit=merged_config.get("ENVELOPE_MODE_LIMIT", 10e-3), sidecar=sidecar, crop=merged_config.get("crop"), - yscale_mode=merged_config.get("YSCALE_MODE", "snr"), - show_plots=True, + save_plots=True, filter_type=merged_config.get("FILTER_TYPE", "gaussian"), filter_order=merged_config.get("FILTER_ORDER", 2), chunk_size=merged_config.get("CHUNK_SIZE"), ) + + # Show the plot (equivalent to old show_plots=True) + if results.get("plot"): + import matplotlib.pyplot as plt + plt.show() if __name__ == "__main__": diff --git a/examples/example_diffusion.py b/examples/example_diffusion.py index dc2d05e..8826d16 100644 --- a/examples/example_diffusion.py +++ b/examples/example_diffusion.py @@ -11,23 +11,23 @@ import numpy as np import matplotlib.pyplot as plt # Import transivent functions -from transivent import ( - process_file, - get_final_events, +from transivent import configure_logging, detect + +# Import building blocks from submodules +from transivent.analysis import ( + detect_events, + calculate_initial_background, + estimate_noise, + analyze_thresholds, +) +from transivent.event_processor import ( process_events_for_diffusion, extract_event_waveforms, calculate_msd_parallel, calculate_acf, fit_diffusion_linear, plot_diffusion_comparison, - detect_events, - calculate_initial_background, - estimate_noise, - analyze_thresholds, ) - -# Configure logging -from transivent import configure_logging configure_logging("INFO") |
