Skip to content

Commit

Permalink
Merge branch 'master' into som_memory
Browse files Browse the repository at this point in the history
  • Loading branch information
ngreenwald committed May 27, 2022
2 parents aaf12bd + 3b44f91 commit 06d3002
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 6 deletions.
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,13 @@ First, get the latest version of the code
git pull
```

Then, run the command below to update the jupyter notebooks to the latest version
Check for Docker updates by running:

```
docker pull angelolab/ark-analysis:latest
```

Then, run the command below to update the Jupyter notebooks to the latest version
```
./start_docker.sh --update
```
Expand All @@ -103,8 +109,6 @@ or
./start_docker.sh -u
```

If the requirements.txt has changed, Docker will rebuild with the new dependencies first.

### WARNING

If you didn't change the name of any of the notebooks within the `scripts` folder, they will be overwritten by the command above!
Expand Down
16 changes: 13 additions & 3 deletions ark/utils/load_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import xarray as xr

from ark.utils.tiff_utils import read_mibitiff
from ark.utils import io_utils as iou
from ark.utils import io_utils as iou, misc_utils


def load_imgs_from_mibitiff(data_dir, mibitiff_files=None, channels=None, delimiter=None,
Expand Down Expand Up @@ -96,8 +96,9 @@ def load_imgs_from_tree(data_dir, img_sub_folder=None, fovs=None, channels=None,
directory containing folders of images
img_sub_folder (str):
optional name of image sub-folder within each fov
fovs (list):
optional list of folders to load imgs from. Default loads all folders
fovs (str, list):
optional list of folders to load imgs from, or the name of a single folder. Default
loads all folders
channels (list):
optional list of imgs to load, otherwise loads all imgs
dtype (str/type):
Expand All @@ -121,6 +122,10 @@ def load_imgs_from_tree(data_dir, img_sub_folder=None, fovs=None, channels=None,
if len(fovs) == 0:
raise ValueError(f"No fovs found in directory, {data_dir}")

# If the fov provided is a single string (`fov_1` instead of [`fov_1`])
if type(fovs) is str:
fovs = [fovs]

if img_sub_folder is None:
# no img_sub_folder, change to empty string to read directly from base folder
img_sub_folder = ""
Expand All @@ -147,6 +152,11 @@ def load_imgs_from_tree(data_dir, img_sub_folder=None, fovs=None, channels=None,
# get the corresponding indices found in channels_no_delim
channels_indices = [channels_no_delim.index(chan.split('.')[0]) for chan in all_channels]

# verify if channels from user input are present in `all_channels`
all_channels_no_delim = [channel.split('.')[0] for channel in all_channels]

misc_utils.verify_same_elements(all_channels_in_folder=all_channels_no_delim,
all_channels_detected=channels_no_delim)
# reorder back to original
channels = [chan for _, chan in sorted(zip(channels_indices, all_channels))]

Expand Down
13 changes: 13 additions & 0 deletions ark/utils/load_utils_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,19 @@ def test_load_imgs_from_tree():

assert loaded_xr.equals(data_xr)

# check when fov is a single string
loaded_xr = \
load_utils.load_imgs_from_tree(temp_dir, img_sub_folder="TIFs", dtype="int16",
fovs='fov0', channels=some_chans)

assert loaded_xr.equals(data_xr[:1, :, :, :2])

# check that an error raises when a channel provided does not exist
with pytest.raises(ValueError):
loaded_xr = \
load_utils.load_imgs_from_tree(temp_dir, img_sub_folder="TIFs", dtype="int16",
channels=['chan4'])

# test loading with data_xr containing float values
with tempfile.TemporaryDirectory() as temp_dir:
fovs, chans, imgs = test_utils.gen_fov_chan_names(num_fovs=1, num_chans=2,
Expand Down
17 changes: 17 additions & 0 deletions docs/_rtd/windows_setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,23 @@ To run the script, you have to use `bash start_docker.sh`. If you run into issue
* Run `wsl sudo apt-get install dos2unix`
* Run `wsl dos2unix start_docker.sh` and `wsl dos2unix update_notebooks.sh`


### Mounting External Drives

If you wish to mount an external drive to the Docker instance you may do so by adding an argument to the execution of the `start_docker.sh` script.

If, for example the data is stored on `X:/path/to/external/data/` where `X:/` is your external drive name, you will need to add:

```bash
bash start_docker.sh --external "/mnt/x/path/to/external/data"
```

`X:/` has to be swapped with `/mnt/x/` to be a valid path on WSL. In addition `--external` has a shorthand notation: `-e`.
```bash
bash start_docker.sh -e "/mnt/x/path/to/external/data"
```


### If you run into more Windows-specific issues

Please open an [issue](https://github.com/angelolab/ark-analysis/issues) on our GitHub page. Note that our codebase has not been extensively tested on Windows.
7 changes: 7 additions & 0 deletions start_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ done
# find lowest open port available
PORT=8888

if [ $update -ne 0 ]
then
bash update_notebooks.sh -u
else
bash update_notebooks.sh
fi

until [[ $(docker container ls | grep 0.0.0.0:$PORT | wc -l) -eq 0 ]]
do
((PORT=$PORT+1))
Expand Down

0 comments on commit 06d3002

Please sign in to comment.