-
Notifications
You must be signed in to change notification settings - Fork 141
Add simulator #150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add simulator #150
Conversation
…d_simulator Conflicts: setup.py
Conflicts: brainiak/utils/fmrisim.py examples/utils/fmrisim_example.py setup.py
brainiak/utils/fmrisim.py
Outdated
| This estimates what noise properties the volume has. The absolute size of | ||
| the autoregression, drift and system noise is not critical but rather | ||
| the relative amounts (because all temporal noise is z scored in the | ||
| average and multiplied by the 'overall' parameter). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the overall parameter? Where is it (it is not a parameter of this function)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is a parameter used in generate_noise to control the overall noise level.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please explain this in the docstring?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay updated
No need to make any change to hyperparamopt
| from itertools import product | ||
| import nibabel | ||
| from scipy import stats | ||
| import nitime.algorithms.autoregressive as ar |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You must add Nitime to the list of dependencies in setup.py.
brainiak/utils/fmrisim.py
Outdated
| def export_stimfunction(stimfunction, | ||
| filename, | ||
| ): | ||
| """ Output a three column text file (onset time, event duration and weight) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a tab-separated values file? If so, please change the docstring to say so.
brainiak/utils/fmrisim.py
Outdated
| # nifti into a numpy array | ||
| if isinstance(volume, str): | ||
| nifti = nibabel.load(volume) # Load the file | ||
| volume = nifti.get_data() # Pull out the data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the only usage of Nibabel in your code (except for the example). Could you please remove it so we do not introduce a dependency on Nibabel? If so, please change the docstring and dependencies in setup.py accordingly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was told that Nibabel is the method we will be using for loading (and in this case writing it is well) in niftis. If there is an alternative, I am happy to use it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is indeed. However, so far we have only been using it in examples, not in BrainIAK code. I would prefer to not add it as a BrainIAK dependency yet, if it is not really necessary. The way I see it, here it is not necessary, because you can load the file outside BrainIAK, like you do now in the example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay fair enough, I have removed it
setup.py
Outdated
| 'numpy', | ||
| 'scikit-learn>=0.18', | ||
| 'scipy', | ||
| 'statsmodels', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not used. Please remove.
tests/utils/test_fmrisim.py
Outdated
| assert np.sum(stimfunction) == np.sum(event_durations * len(onsets)) / \ | ||
| tr_duration, "Event number" | ||
| assert np.sum(stimfunction) == np.sum(event_durations * len(onsets)) * \ | ||
| 1000, "Event number" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should break the line before binary operators:
https://www.python.org/dev/peps/pep-0008/#should-a-line-break-before-or-after-a-binary-operator
|
The testing error is because of a bug in Nitime: Let's wait a couple of days for the Nitime maintainer to make a release including the bug fix before deciding how to proceed. |
|
Jenkins, retest this please. |
|
There is a new Nitime release which solves the installation problem. @CameronTEllis, the failure is caused by low coverage now. Run |
|
Hi Mihai,
Thanks for following this up. My pr-check still isn't working (the coverage
is not being run). How would you like me to proceed? In the meantime I am
adding some some new tests now that should get my coverage up.
Thanks,
Cameron
…On Thu, Dec 15, 2016 at 11:59 PM, Mihai Capotă ***@***.***> wrote:
There is a new Nitime release which solves the installation problem.
@CameronTEllis <https://github.com/CameronTEllis>, the failure is caused
by low coverage now. Run pr-check.sh yourself followed by coverage report
to see. (I will fix run-tests.sh to show the low coverage by itself.)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#150 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AKf6H72Z09XNW1T7QlqMxRUienQ-OTArks5rIhqygaJpZM4LJPAE>
.
--
*Thank you,*
*Cameron Ellis*
*PhD Candidate (Turk-Browne lab) Department of Psychology Princeton
University Peretsman-Scully Hall, Room 321 Princeton, NJ 08544 p:
609.258.7493*
|
| timing_file : string | ||
| The filename (with path) to a three column timing file (FSL) to | ||
| make the events. Still requires tr_duration and total_time |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tr_duration is not a parameter of this function.
| total_time, | ||
| tr_duration, | ||
| weights=[1], | ||
| timing_file=None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should add a paragraph to the docstring (before the parameters) explaining there are two ways to call the function: either with a timing file, or with onsets.
|
|
||
| # Pull out the weight, set as a float | ||
| weights[event_counter] = float(line[0:line.find('\t')]) | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is correct, but not Pythonic. Consider something like this:
for line in f:
onset, duration, weight = line.strip().split()
onsets.append(float(onset))
durations.append(float(duration))
weights.append(float(weight))
brainiak/utils/fmrisim.py
Outdated
| stimfunction = [0] * round(total_time * temporal_resolution) | ||
|
|
||
| # Cycle through the onsets | ||
| for onset_counter in list(range(0, len(onsets))): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for list and 0.
brainiak/utils/fmrisim.py
Outdated
| Apply the convolution of the HRF and stimulus time course to the | ||
| volume. | ||
| volume. This requires discriti |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"discriti"?
brainiak/utils/fmrisim.py
Outdated
| What is the path to the mask to be loaded? If set to self then it | ||
| makes a mask from the volume supplied (by averaging across time | ||
| points and changing the range). If empty then it defaults to an | ||
| MNI152 grey matter mask. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This gives a special meaning to the path "self". It would be better to introduce an extra boolean parameter, perhaps called self_mask.
brainiak/utils/fmrisim.py
Outdated
| # tmp = str(noise_dict['physiological_sigma'] ** 2 / total_var * 100)[0:5] | ||
| # print('Physiological noise:\t' + tmp) | ||
| # tmp = str(noise_dict['system_sigma'] ** 2 / total_var * 100)[0:5] | ||
| # print('System noise:\t\t\t' + tmp) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove or turn into debug log messages.
brainiak/utils/fmrisim.py
Outdated
| stimfunction, | ||
| tr_duration, | ||
| mask=None, | ||
| noise_dict={'overall': 0.1}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default value is only evaluated once and shared between all calls:
https://docs.python.org/3/tutorial/controlflow.html#default-argument-values
You should set None as the default value and make the assignment in the function body.
brainiak/utils/fmrisim.py
Outdated
| ) | ||
|
|
||
| noise_system = _generate_noise_system(dimensions_tr=dimensions_tr, | ||
| ) * noise_dict['system_sigma'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This style is appropriate for code that is expected to change. Do you expect to keep adding parameters to the _generate_noise_system call? Otherwise, consider this for readability:
noise_system = _generate_noise_system(dimensions_tr=dimensions_tr)
* noise_dict['system_sigma']
setup.py
Outdated
| install_requires=[ | ||
| 'cython', | ||
| 'mpi4py', | ||
| 'nibabel', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not used in BrainIAK. Move it to examples/utils/requirements.txt.
|
@CameronTEllis, please speak up if you need help with the testing errors. |
|
Hi Mihai,
I am not sure what is meant by this. What errors are you referring to? Why
did the most recent commit fail?
Thanks,
Cameron
…On Tue, Jan 10, 2017 at 10:20 AM, Mihai Capotă ***@***.***> wrote:
@CameronTEllis <https://github.com/CameronTEllis>, please speak up if you
need help with the testing errors.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#150 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AKf6H1YVvJ4MPeWfhqZITbfagaBshLLoks5rQqSkgaJpZM4LJPAE>
.
--
*Thank you,*
*Cameron Ellis*
*PhD Candidate (Turk-Browne lab) Department of Psychology Princeton
University Peretsman-Scully Hall, Room 321 Princeton, NJ 08544 p:
609.258.7493*
|
|
Click on the "Details" link next to the failed Travis build. Then click on any of the failed jobs to see the logs. Here is an the relevant part from at the end of one of the logs: If you run |
|
Also, please merge the latest changes from master. You can also do it on github.com using the "Update branch" button after you push all your changes. |
|
Jenkins, retest this please. |
|
@CameronTEllis, there were other errors unrelated to your code that were fixed. Please merge the latest commits from master (you can press "Update branch" in the PR on github.com and then pull the changes to your local repository). However, there is also a problem with your code, which you can see when running the tests: Specifically, |
|
Thank you for the contribution, @CameronTEllis. I suggest you start a new branch for master for your next contribution. You should delete this branch; you can press the "Delete branch" button at the end of the PR page on github.com (you still need to delete it from your local repository). |
#150) * Experimental utils for copying directories to other machines in the cluster using Ray. * Test copying directory functionality. * Small fix.
Updated simulator extensively