Skip to content

Commit 4da0c08

Browse files
Merge pull request #362 from marcodallavecchia/root-mass-reproducibility
Measuring Root Mass updated results
2 parents 5a50ce3 + ad79637 commit 4da0c08

1 file changed

Lines changed: 20 additions & 12 deletions

File tree

episodes/07-thresholding.md

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ print("Found automatic threshold t = {}.".format(t))
383383
```
384384

385385
```output
386-
Found automatic threshold t = 0.4172454549881862.
386+
Found automatic threshold t = 0.4116003928683858.
387387
```
388388

389389
For this root image and a Gaussian blur with the chosen sigma of 1.0,
@@ -512,7 +512,7 @@ measure_root_mass(filename="data/trial-016.jpg", sigma=1.5)
512512
```
513513

514514
```output
515-
0.0482436835106383`
515+
0.04907247340425532
516516
```
517517

518518
Now we can use the function to process the series of four images shown above.
@@ -525,20 +525,28 @@ and the filenames all start with the **trial-** prefix and
525525
end with the **.jpg** suffix.
526526

527527
```python
528-
all_files = glob.glob("data/trial-*.jpg")
528+
all_files = sorted(glob.glob("data/trial-*.jpg"))
529529
for filename in all_files:
530530
density = measure_root_mass(filename=filename, sigma=1.5)
531531
# output in format suitable for .csv
532532
print(filename, density, sep=",")
533533
```
534534

535535
```output
536-
data/trial-016.jpg,0.0482436835106383
537-
data/trial-020.jpg,0.06346941489361702
538-
data/trial-216.jpg,0.14073969414893617
539-
data/trial-293.jpg,0.13607895611702128
536+
data/trial-016.jpg,0.04907247340425532
537+
data/trial-020.jpg,0.06381366356382978
538+
data/trial-216.jpg,0.14205152925531914
539+
data/trial-293.jpg,0.13665791223404256
540540
```
541541

542+
::::::::::::::::::::::::::::::::::::::::: callout
543+
544+
Compare your results with the values above. Do they match exactly? You may find that certain decimal values differ slightly, even when using identical input parameters.
545+
546+
This variation often stems from the specific versions of your installed packages (such as `numpy` or `scikit-image`). As these libraries evolve, updates can introduce subtle changes in numerical handling, underlying algorithms, or rounding logic. This highlights why reproducible environments, as well as reproducible code, are essential for consistent scientific computing.
547+
548+
:::::::::::::::::::::::::::::::::::::::::
549+
542550
::::::::::::::::::::::::::::::::::::::: challenge
543551

544552
## Ignoring more of the images -- brainstorming (10 min)
@@ -650,7 +658,7 @@ def enhanced_root_mass(filename, sigma):
650658
return density
651659

652660

653-
all_files = glob.glob("data/trial-*.jpg")
661+
all_files = sorted(glob.glob("data/trial-*.jpg"))
654662
for filename in all_files:
655663
density = enhanced_root_mass(filename=filename, sigma=1.5)
656664
# output in format suitable for .csv
@@ -661,10 +669,10 @@ The output of the improved program does illustrate that the white circles
661669
and labels were skewing our root mass ratios:
662670

663671
```output
664-
data/trial-016.jpg,0.046250166223404256
665-
data/trial-020.jpg,0.05886968085106383
666-
data/trial-216.jpg,0.13712117686170214
667-
data/trial-293.jpg,0.13190342420212767
672+
data/trial-016.jpg,0.046261136968085106
673+
data/trial-020.jpg,0.05887167553191489
674+
data/trial-216.jpg,0.13712067819148935
675+
data/trial-293.jpg,0.1319044215425532
668676
```
669677
:::::::::::::::::::::::::::::::::::::::::: spoiler
670678

0 commit comments

Comments
 (0)