From b79a617edffd81646ecf6bcf1a7b5b1e6fd204eb Mon Sep 17 00:00:00 2001 From: Jonny Taylor Date: Tue, 25 Jan 2022 15:12:33 +0000 Subject: [PATCH] Update installation instructions to include issues we encountered on the RPi. Add a clarifying comment to the gating code --- README.md | 17 ++++++++++++++++- .../cli/prospective_optical_gating.py | 4 ++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index aa14da9..2f3ff58 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,11 @@ Then, to install on any platform, run the following command: `python3 -m pip install --user git+https://github.com/Glasgow-ICG/open-optical-gating.git@main#egg=open-optical-gating` -(Note: if you get the error `python3: command not found`, substitute `python` for `python3` throughout these instructions) +If you get the error `python3: command not found`, substitute `python` for `python3` throughout these instructions. + +If you get an error about not being able to write to `site-packages`, run the following command instead: + +`python3 -m pip install --prefix=/home/pi/.local git+https://github.com/Glasgow-ICG/open-optical-gating.git@main#egg=open-optical-gating` ### Installation - troubleshooting @@ -62,6 +66,10 @@ Fix by running `python3 -m pip install numpy`, and then rerun the installation c - If you are installing inside a virtual environment, rerun the install command but omit the `--user` flag. [A newer version of `pip` would have warned you about the problem - see above] - If you have a *very* old version of pip installed, you will see this error after a suspiciously fast installation process. Run `python3 -m pip install --upgrade pip` and then repeat the original installation instructions. +- Installation fails, with the Raspberry Pi hanging completely and requiring a reboot. This can happen if the Pi runs out of memory. +You can probably fix this by quitting all other programs that are currently running, other than the terminal window. +TeamViewer will use up most of the RAM on a Pi with 1GB RAM, so you probably need to run the initial install in person, without using TeamViewer. +(Note that TeamViewer is also likely to use too much CPU for you to be able to run live optical gating while connected over TeamViewer). ## Testing an installation @@ -91,6 +99,13 @@ Instead of the standard `pip install` command given above, run the following com `python3 -m pip install --src "." -e git+https://github.com/Glasgow-ICG/open-optical-gating.git@main#egg=open-optical-gating` +As with the main install command above, you may need to add `--prefix=/home/pi/.local` on the RPi. + +*Upgrading* is awkward because we aren't recording proper version numbers for our modules yet. +If you have the editable source then it should be sufficient to do a `git pull`. +If you don't have the source (which is probably the case for `optical_gating_alignment`) then you probably need to specify `--force-reinstall`. +I still need to test that. In the past I have simply gone into ` /home/pi/.local/lib/python3.7/site-packages` and manually deleted the source and egg. + ### Tests for developers We are currently in the process of building a pytest framework for this repository. diff --git a/open_optical_gating/cli/prospective_optical_gating.py b/open_optical_gating/cli/prospective_optical_gating.py index 9201ee4..9aa3b98 100644 --- a/open_optical_gating/cli/prospective_optical_gating.py +++ b/open_optical_gating/cli/prospective_optical_gating.py @@ -105,6 +105,10 @@ def predict_trigger_wait(self, full_frame_history, targetSyncPhase, frameInterva logger.debug("Fit failed due to too few frames") return -1 + # We need to look back through the recent frame history and pick out 'framesForFit' frames + # to use in our linear fit. Note the care taken here to only pass those relevant frames + # to get_metadata_from_list, so that the time taken inside that function doesn't get longer + # and longer as the experiment continues (when our history is large) frame_history = pa.get_metadata_from_list( full_frame_history[-framesForFit:], ["timestamp", "unwrapped_phase", "sad_min"] )