Skip to content

Commit

Permalink
update imagej
Browse files Browse the repository at this point in the history
  • Loading branch information
BIN LI committed Aug 22, 2021
1 parent 91f3746 commit 0219e64
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 40 deletions.
41 changes: 5 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,44 +9,13 @@ Intensity-based registration algorithm repository: https://github.com/uw-loci/sh
|<img src="https://github.com/uw-loci/he_shg_synth_workflow/blob/master/thumbnails/he.jpg" width="320">|<img src="https://github.com/uw-loci/he_shg_synth_workflow/blob/master/thumbnails/shg.jpg" width="320">|

## Required packages
Install required packages in a virtual environment, commands for anaconda/miniconda (https://www.anaconda.com/distribution/) are listed
* python==3.6.x
Install [anaconda/miniconda](https://docs.conda.io/en/latest/miniconda.html)
Required packages
```
conda create --name [NAME_ENV] python=3.6
conda activate [NAME_ENV]
$ conda env create --name syn --file env.yml
$ conda activate syn
```
* matplotlib==3.1.2
```
conda install -c conda-forge matplotlib=3.1.2
```
* numpy==1.17.4
```
conda install -c anaconda numpy=1.17.4
```
* pandas==0.25.3
```
conda install -c anaconda pandas=0.25.3
```
* Pillow==5.3.0
```
conda install -c anaconda pillow=5.3.0
```
* pyimagej==0.4.0
```
conda install -c conda-forge pyimagej
```
* scikit-image==0.16.2
```
conda install -c anaconda scikit-image=0.16.2
```
* tqdm==4.42.0
```
conda install -c conda-forge tqdm=4.42.0
```
* pytorch>=1.3.1
```
conda install pytorch torchvision cudatoolkit=10.1 -c pytorch
```

## Download example testing data, trained model weights, FIJI
Execute download.py
```
Expand Down
10 changes: 6 additions & 4 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def main():
parser.add_argument('--load-multiple-gpu-weights', type=int, default=1, help='1: multiple gpu weights, 0: single gpu weghts')
parser.add_argument('--input-folder', type=str, default='default', help='input_test + _FOLDERNAME')
parser.add_argument('--intensity', type=tuple, default=(20, 180), help='output intensity rescale')
parser.add_argument('--pilot', type=int, default=0, help='1: only process the first image, 0: process all images')
parser.add_argument('--pilot', type=int, default=1, help='1: only process the first image, 0: process all images')

args = parser.parse_args()

Expand Down Expand Up @@ -104,7 +104,7 @@ def demo(args):
model.to(device)

print('loading ImageJ, please wait')
ij = imagej.init('fiji/fiji/Fiji.app/')
ij = imagej.init('fiji/Fiji.app/')

# use for SHG
TASK = args.input_folder
Expand Down Expand Up @@ -165,25 +165,27 @@ def demo(args):
io.imsave(OUTPUT_PATCH_DIR+img_name, result_patch)

print('stitching, please wait...')
os.makedirs(CHANNEL_DIR, exist_ok=True)
params = {'type': 'Positions from file', 'order': 'Defined by TileConfiguration',
'directory':OUTPUT_PATCH_DIR, 'ayout_file': 'TileConfiguration.txt',
'fusion_method': 'Linear Blending', 'regression_threshold': '0.30',
'max/avg_displacement_threshold':'2.50', 'absolute_displacement_threshold': '3.50',
'compute_overlap':False, 'computation_parameters': 'Save computation time (but use more RAM)',
'image_output': 'Write to disk', 'output_directory': CHANNEL_DIR}
plugin = "Grid/Collection stitching"
ij.py.run_plugin(plugin, params)
ij.py.run_plugin(plugin, params)

output_name = os.path.join(OUTPUT_DIR, fn)
listOfChannels = [f for f in os.listdir(CHANNEL_DIR)]
c1 = io.imread(os.path.join(CHANNEL_DIR, listOfChannels[0]))
c1 = c1[:img.shape[0], :img.shape[1]]
c1 = img_as_ubyte(c1)
c1 = exposure.rescale_intensity(c1, in_range=args.intensity, out_range=(0, 255))
c1 = exposure.rescale_intensity(c1, in_range=(0, 255), out_range=(0, 1))
print(str(k+1)+"/" + str(len(files)) + " output saved as: " + output_name)
io.imsave(output_name, img_as_ubyte(c1))
if args.pilot:
break

if __name__ == '__main__':
main()
main()

0 comments on commit 0219e64

Please sign in to comment.