Skip to content
This repository has been archived by the owner on Oct 25, 2024. It is now read-only.

Documentation and bugfixes for week06 #129

Open
wants to merge 4 commits into
base: week06
Choose a base branch
from

Conversation

twemyss
Copy link

@twemyss twemyss commented Nov 18, 2020

Answers #100

@twemyss
Copy link
Author

twemyss commented Nov 18, 2020

Answers #101

@twemyss
Copy link
Author

twemyss commented Nov 19, 2020

For the brain sample issue in #102, the following output is obtained:

> git bisect reset
> git bisect start
> git bisect good 034d01f  
> git bisect bad 02fd879
> git bisect run ../test.sh

running ../test.sh
Bisecting: 5 revisions left to test after this (roughly 3 steps)
[21aa66f6bbebd4e8db7307ad13db7b7b942641da] Adds some description and help to the arguments of the script
running ../test.sh
Bisecting: 2 revisions left to test after this (roughly 2 steps)
[a86f40870787f49c6fc41a122a328d184e3b1ff9] Uses numpy to calculate the average
running ../test.sh
Bisecting: 0 revisions left to test after this (roughly 1 step)
[6cc235021c8af2519fcc24a4cb76f5cd3cdf4d0f] With Numpy I can calculate the mean without to iterate over each column
running ../test.sh
a86f40870787f49c6fc41a122a328d184e3b1ff9 is the first bad commit
commit a86f40870787f49c6fc41a122a328d184e3b1ff9
Author: Charlene Bultoc <c.bultoc@neurolab.ac.uk>
Date:   Sun Sep 29 05:35:31 2019 +0100

    Uses numpy to calculate the average

 sagital_brain.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
bisect run success

when using the following test.sh script, placed in the parent folder of the brain repository

#!/usr/bin/env bash

rm brain_sample.csv
cp ../brain_sample_bad.csv brain_sample.csv

python3 sagital_brain.py

str=0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0
if [[ $(< brain_average.csv) != "$str" ]]; then
    exit 1
fi
exit 0

and the following sample brain_sample_bad.csv which is also stored in the parent folder containing the brain repository.

0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1

This solution isn't ideal - it would be better to parse the output averages CSV in python and check the values, to make it whitespace agnostic.

@twemyss
Copy link
Author

twemyss commented Nov 19, 2020

The above comment also answers #135 (comment)

twemyss added a commit to twemyss/rsd-sagital_average that referenced this pull request Nov 19, 2020
@twemyss
Copy link
Author

twemyss commented Nov 19, 2020

The following python script is a tidier and safer alternative to the bash script above for #135, and can be used with git bisect to yield the same answer via changing the git bisect run ../test.sh line to git bisect run python3 ../test.py, where test.py is the file in the parent directory containing the following contents.

#!/usr/bin/env python3

import numpy as np

# Make new output file
data_input = np.zeros((20, 20))
data_input[-1, :] = 1
np.savetxt("brain_sample.csv", data_input, fmt='%d', delimiter=',')

# Run sagital brain file to generate output
exec(open("sagital_brain.py").read())

# Load output
loaded = np.loadtxt('brain_average.csv', delimiter=',')

# Expected output
expected = np.array([0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0]);

# Check the values are identical
np.testing.assert_array_equal(loaded, expected);

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant