4. Computing Normalization Statisticsο
Both prediction scripts normalise every frame with a per-channel mean and standard deviation:
# Top of PredictEF.py and PredictSegmentation.py
MEAN = [0.128, 0.129, 0.130]
STD = [0.196, 0.196, 0.197]
These defaults come from the EchoNet-Dynamic training set and work well on
EchoNet-like data. If your videos come from a different scanner, view, or
contrast, recomputing these statistics on your own data can reduce the domain
shift and improve segmentation/EF accuracy. CalculateStats.py does exactly
that.
Optional step
You only need this chapter if you want to retune the MEAN/STD for your own
dataset. To just run the models on EchoNet-style data, keep the defaults and skip
ahead to Segmentation.
4.1. Configure the pathsο
INPUT_DIR points at the demo videos; for meaningful statistics, point it at
your full dataset instead:
INPUT_DIR = r"...\EchoNet-dynamic\demo\video" # use your full Videos\ folder for real stats
CSV_PATH = None # or r"...\FileList.csv" (TRAIN split only)
Variable |
Meaning |
|---|---|
|
Folder containing the |
|
Optional |
The demo is just a smoke test β use the full dataset for real stats
Statistics from a single demo video are not representative. For real MEAN/STD
values, set INPUT_DIR to the Videos/ folder of the open
EchoNet-Dynamic dataset and set CSV_PATH
to its FileList.csv β that file ships with the dataset and already contains the
Split column used to pick the training set.
4.2. Two modes: training-only vs full scanο
The script decides automatically how to pick videos:
Training Set Only β if
CSV_PATHpoints to a CSV that has both aFileNameand aSplitcolumn, only the rows whereSplit == TRAINare used. Filenames without an extension get.aviappended, and missing files are skipped.Full Dataset β used when no CSV is given, the file is missing, the required columns are absent, or no
TRAINrows are found. Every.avi/.mp4in the folder is measured.
Why training-only matters
Statistics should be computed on the training split only, never the test set,
to avoid leaking information. Provide a FileList.csv with a Split column to
keep this clean.
4.3. Run the scriptο
conda activate echonet
python scripts/CalculateStats.py
It streams every frame, converts BGRβRGB, resizes to 112 Γ 112, scales to
[0, 1], and accumulates per-channel sums to compute:
Typical output (pointed at the full EchoNet-Dynamic dataset):
π CSV file detected: ...\EchoNet-Dynamic\FileList.csv
π― Found 7460 training videos in CSV. Verifying local files...
π Final count: 7460 videos ready for processing. Starting calculation...
============================================================
π Normalization parameters for [Training Set Only] calculated!
============================================================
MEAN = [0.128, 0.129, 0.130]
STD = [0.196, 0.196, 0.197]
============================================================
4.4. Use the resultο
Copy the printed MEAN and STD lines into the configuration block at the top
of both PredictEF.py and PredictSegmentation.py, replacing the defaults.
The next run of either script will use your datasetβs statistics.
Requires pandas
This script imports pandas to read the CSV. Install it with
pip install pandas if you have not already (see Installation).