Skip to content

Commit

Permalink
Merge pull request #43 from sct-pipeline/refactor_stat
Browse files Browse the repository at this point in the history
Refactoring of statistics
  • Loading branch information
PaulBautin authored Sep 4, 2020
2 parents fa7b3f2 + 8da9edc commit 1808517
Show file tree
Hide file tree
Showing 5 changed files with 255 additions and 286 deletions.
56 changes: 32 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,6 @@ Evaluate the sensitivity of atrophy detection with SCT. The algorithm works as f
- Segment the cord
- Compute CSA --> CSA(sI, rX, tY)

After everything is done, compute stats:
- intra-subject MEAN: MEAN[CSA(sI, rX, :)] --> MEAN_intra(sI, rX)
- intra-subject STD (per subject): STD[CSA(sI, rX, :)] --> STD_intra_sub(sI, rX)
- intra-subject COV (per subject): STD[CSA(sI, rX, :)] / MEAN[CSA(sI, rX, :)] --> COV_intra_sub(sI, rX)
- intra-subject STD: MEAN[STD_intra_sub(:, rX)] --> STD_intra(rX)
- intra-subject COV: MEAN[COV_intra_sub(:, rX)] --> COV_intra(rX)
- inter-subject STD: STD[MEAN_intra(:, rX)] --> STD_inter(rX)

- rescale_estimated_subject MEAN: MEAN[CSA(sI, rX, :)] / MEAN[CSA(sI, 1, :)] --> MEAN_rescale_estimated_subject(sI, rX)
- rescale_estimated (across subjects) MEAN: MEAN[MEAN_rescale_estimated_subject(:, rX)] --> MEAN_rescale_estimated(rX)
- rescale_estimated (across subjects) STD: STD[MEAN_rescale_estimated_subject(:, rX)] --> STD_rescale_estimated(rX)

- error (across subjects) MEAN: MEAN[MEAN_error_intra(:, rX)]
- error (across subjects) STD: STD[MEAN_error_intra(:, rX)]
- sample size: [(z(uncertainty) + z(power))^2 * (2 * STD[MEAN(:, rX)]^2)] / [MEAN[CSA(sI, 1, :)] - MEAN[CSA(sI, rX, :)]]

Plot results:
- STD_intersub
- Mean and STD inter-subject error percentage in function of rescaling
- sample size: minimum number of patients to detect an atrophy of X with Y% power and Z% uncertainty
- CSA values boxplot in function of rescaling
- Error values boxplot in function of rescaling

# How to run

This code has been tested using Python 3.7.
Expand Down Expand Up @@ -63,7 +40,7 @@ sct_run_batch -config config_sct_run_batch.yml

To output statistics, run in Dataset
~~~
csa_rescale_stat -i csa_atrophy_results/results -o csa_atrophy_results -config config_script.yml -v
csa_rescale_stat -i csa_atrophy_results/results -o csa_atrophy_results -config config_script.yml -fig
~~~

# Quality Control
Expand All @@ -82,3 +59,34 @@ are present in the derivatives/ folder of the dataset, otherwise labeling will b
~~~
sct_run_batch -config config_sct_run_batch.yml
~~~

# Statistics

After everything is done, compute stats:
Per-subject stat: Panda dataframe `df_sub`:
- intra-subject MEAN: MEAN[CSA(sI, rX, :)] --> MEAN_intra(sI, rX): `df_sub['mean']`
- intra-subject STD: STD[CSA(sI, rX, :)] --> STD_intra(sI, rX): `df_sub['std']`
- intra-subject COV: STD[CSA(sI, rX, :)] / MEAN[CSA(sI, rX, :)] --> COV_intra(sI, rX): `df_sub['cov']`
- rescale_estimated_subject MEAN: MEAN[CSA(sI, rX, :) / CSA(sI, 1, :)] --> MEAN_rescale_estimated_subject(sI, rX): `df_sub['rescale_estimated']`
- intra-subject error MEAN: MEAN[CSA(sI, rX, :)] - (rX^2 * MEAN[CSA(sI, 1, :)]) --> MEAN_error_intra(sI, rX): `df_sub['error']`
- intra-subject error in percentage MEAN: [MEAN[CSA(sI, rX, :)] - (rX^2 * MEAN[CSA(sI, 1, :)])] / MEAN[CSA(sI, rX, :)] --> MEAN_error_intra_perc(sI, rX): `df_sub['perc_error']`

Across-subject stats: Panda dataframe `df_rescale`
- intra-subject STD: MEAN[STD_intra(:, rX)] --> STD_intra(rX): `df_rescale['std_intra']`
- intra-subject COV: MEAN[COV_intra_sub(:, rX)] --> COV_intra(rX): `df_rescale['cov']`
- inter-subject STD: STD[MEAN_intra(:, rX)] --> STD_inter(rX): `df_rescale['std_inter']`
- rescale_estimated (across subjects) MEAN: MEAN[MEAN_rescale_estimated_subject(:, rX)] --> MEAN_rescale_estimated(rX): `df_rescale['mean_rescale_estimated']`
- rescale_estimated (across subjects) STD: STD[MEAN_rescale_estimated_subject(:, rX)] --> STD_rescale_estimated(rX): `df_rescale['std_rescale_estimated']`
- error in percentage (across subjects) MEAN: MEAN[MEAN_error_intra(:, rX)]
- error in percentage (across subjects) STD: STD[MEAN_error_intra(:, rX)]

Power analysis:
- sample size: [(z(uncertainty) + z(power))^2 * (2 * STD[MEAN(:, rX)]^2)] / [MEAN[CSA(sI, 1, :)] - MEAN[CSA(sI, rX, :)]]

Plot results:
- STD_intersub
- Mean and STD inter-subject error percentage in function of rescaling
- sample size: minimum number of patients to detect an atrophy of X with Y% power and Z% uncertainty
- CSA values boxplot in function of rescaling
- Error values boxplot in function of rescaling

6 changes: 6 additions & 0 deletions config_correction.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FILES_SEG:
- sub-amu01_T1w.nii.gz
FILES_GMSEG:

FILES_LABEL:
- sub-amu01_T1w.nii.gz
8 changes: 8 additions & 0 deletions config_script.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ stats:
atrophy_sample: 7.7
conf: 0.95
power: 0.8
fig:
sample_size:
atrophy_sample: 7.7
conf: 1.96
power:
- 0.84
- 1.282


# affine_transfo.py
# -----------------
Expand Down
Loading

0 comments on commit 1808517

Please sign in to comment.