diff --git a/code/external/deepmatching_1.2.2_c++_linux/Makefile b/code/external/deepmatching_1.2.2_c++_linux/Makefile index 3f31795..d16e330 100755 --- a/code/external/deepmatching_1.2.2_c++_linux/Makefile +++ b/code/external/deepmatching_1.2.2_c++_linux/Makefile @@ -1,46 +1,47 @@ CC=g++ OS_NAME=$(shell uname -s) ifeq ($(OS_NAME),Linux) #old# LAPACKLDFLAGS=/usr/lib64/atlas/libsatlas.so # single-threaded blas #LAPACKLDFLAGS=/usr/lib/atlas-base/libatlas.so /usr/lib/libblas/libblas.so - LAPACKLDFLAGS=/usr/lib64/atlas/libtatlas.so.3.10 # multi-threaded blas + #LAPACKLDFLAGS=/usr/lib64/atlas/libtatlas.so.3.10 # multi-threaded blas for deneb1 + LAPACKLDFLAGS=/ssoft/spack/cornalin/v1/opt/spack/linux-rhel7-x86_E5v4_Mellanox/gcc-7.1.0/openblas-0.2.19-ylrirtidrpbdgxmcwipnhx4rhla4j4fm/lib/libopenblas_haswellp-r0.2.19.so #multithreaded blas for fidis BLAS_THREADING=-D MULTITHREADED_BLAS # remove this if wrong endif ifeq ($(OS_NAME),Darwin) # Mac OS X LAPACKLDFLAGS=-framework Accelerate # for OS X endif LAPACKCFLAGS=-Dinteger=int $(BLAS_THREADING) #old# #STATICLAPACKLDFLAGS=-fPIC -Wall -g -fopenmp -static -static-libstdc++ /home/lear/douze/tmp/jpeg-6b/libjpeg.a /usr/lib64/libpng.a /usr/lib64/libz.a /usr/lib64/libblas.a /usr/lib/gcc/x86_64-redhat-linux/4.9.2/libgfortran.a /usr/lib/gcc/x86_64-redhat-linux/4.9.2/libquadmath.a # statically linked version STATICLAPACKLDFLAGS=-fPIC -Wall -g -fopenmp -static -static-libstdc++ /home/lear/douze/tmp/jpeg-6b/libjpeg.a /usr/lib/x86_64-linux-gnu/libpng.a /usr/lib/x86_64-linux-gnu/libz.a /usr/lib/libblas/libblas.a /usr/lib/gcc/x86_64-linux-gnu/4.8/libgfortran.a /usr/lib/gcc/x86_64-linux-gnu/4.8/libquadmath.a # statically linked version -CFLAGS= -fPIC -Wall -g -std=c++11 $(LAPACKCFLAGS) -fopenmp -DUSE_OPENMP -O3 +CFLAGS= -fPIC -Wall -g -std=c++11 $(LAPACKCFLAGS) -fopenmp -DUSE_OPENMP -O3 -march=native LDFLAGS=-fPIC -Wall -g -ljpeg -lpng -fopenmp CPYTHONFLAGS=-I/usr/include/python2.7 SOURCES := $(shell find . -name '*.cpp' ! -name 'deepmatching_matlab.cpp') OBJ := $(SOURCES:%.cpp=%.o) HEADERS := $(shell find . -name '*.h') all: deepmatching .cpp.o: %.cpp %.h $(CC) -o $@ $(CFLAGS) -c $+ deepmatching: $(HEADERS) $(OBJ) $(CC) -o $@ $^ $(LDFLAGS) $(LAPACKLDFLAGS) deepmatching-static: $(HEADERS) $(OBJ) $(CC) -o $@ $^ $(STATICLAPACKLDFLAGS) python: $(HEADERS) $(OBJ) # swig -python $(CPYTHONFLAGS) deepmatching.i # not necessary, only do if you have swig compiler g++ $(CFLAGS) -c deepmatching_wrap.c $(CPYTHONFLAGS) g++ -shared $(LDFLAGS) $(LAPACKLDFLAGS) deepmatching_wrap.o $(OBJ) -o _deepmatching.so $(LIBFLAGS) clean: rm -f $(OBJ) deepmatching *~ *.pyc .gdb_history deepmatching_wrap.o _deepmatching.so deepmatching.mex??? diff --git a/code/external/deepmatching_1.2.2_c++_linux/deepmatching b/code/external/deepmatching_1.2.2_c++_linux/deepmatching index 41f0134..cf90a25 100755 Binary files a/code/external/deepmatching_1.2.2_c++_linux/deepmatching and b/code/external/deepmatching_1.2.2_c++_linux/deepmatching differ diff --git a/fiji_script_vertical_combination.py b/fiji_script_vertical_combination.py index 4b715da..a05ed9d 100644 --- a/fiji_script_vertical_combination.py +++ b/fiji_script_vertical_combination.py @@ -1,77 +1,89 @@ #@String parameter_file from ij import IJ, ImagePlus from ij.io import Opener, FileSaver from ij.plugin import RGBStackMerge, StackCombiner, Resizer from ij.process import ImageConverter -from ij.plugin import Resizer +from ij.plugin import Resizer, ZProjector, ImageCalculator import json #import file paths json_file = open(parameter_file,'r') text = json_file.read() files = json.loads(text) json_file.close() #Instanciate necessary classes opener = Opener() RGB_stack_merge = RGBStackMerge() stack_combiner = StackCombiner() resizer = Resizer() +ic = ImageCalculator() +z_proj = ZProjector() #Open images -unregistered_GC6s_info = opener.getTiffFileInfo(files['GC6s_input']) +unregistered_GC6s_info = opener.getTiffFileInfo(files['output_dir']+'/GC6s_preprocessed.tif') unregistered_GC6s_imp = opener.openTiffStack(unregistered_GC6s_info) -unregistered_tdTom_info = opener.getTiffFileInfo(files['tdTom_input']) +unregistered_tdTom_info = opener.getTiffFileInfo(files['output_dir']+'/GC6s_preprocessed.tif') unregistered_tdTom_imp = opener.openTiffStack(unregistered_tdTom_info) registered_GC6s_info = opener.getTiffFileInfo(files['GC6s_registered']) registered_GC6s_imp = opener.openTiffStack(registered_GC6s_info) registered_tdTom_info = opener.getTiffFileInfo(files['tdTom_registered']) registered_tdTom_imp = opener.openTiffStack(registered_tdTom_info) vector_info = opener.getTiffFileInfo(files['vectors_out']) vector_imp = opener.openTiffStack(vector_info) #Convert fluorescence images to 32-bit and adjust brightness IJ.run(unregistered_GC6s_imp,"32-bit","slices") IJ.run(registered_GC6s_imp,"32-bit","slices") IJ.run(unregistered_tdTom_imp,"32-bit","slices") IJ.run(registered_tdTom_imp,"32-bit","slices") IJ.run(unregistered_GC6s_imp, "Enhance Contrast", "saturated=0.35"); IJ.run(registered_GC6s_imp, "Enhance Contrast", "saturated=0.35"); IJ.run(unregistered_tdTom_imp, "Enhance Contrast", "saturated=0.35"); IJ.run(registered_tdTom_imp, "Enhance Contrast", "saturated=0.35"); IJ.run(vector_imp, "Enhance Contrast", "saturated=0.35"); #Remove first frame from registered and unregistered stacks IJ.run(unregistered_GC6s_imp, "Delete Slice", "") IJ.run(registered_GC6s_imp, "Delete Slice", "") IJ.run(unregistered_tdTom_imp, "Delete Slice", "") IJ.run(registered_tdTom_imp, "Delete Slice", "") #Upsample to resolution of vector image IJ.run(unregistered_GC6s_imp, "Size...", "width=%d height=%d depth=%d interpolation=None" % (vector_imp.getWidth(),vector_imp.getHeight(),vector_imp.getStackSize())) IJ.run(registered_GC6s_imp, "Size...", "width=%d height=%d depth=%d interpolation=None" % (vector_imp.getWidth(),vector_imp.getHeight(),vector_imp.getStackSize())) IJ.run(unregistered_tdTom_imp, "Size...", "width=%d height=%d depth=%d interpolation=None" % (vector_imp.getWidth(),vector_imp.getHeight(),vector_imp.getStackSize())) IJ.run(registered_tdTom_imp, "Size...", "width=%d height=%d depth=%d interpolation=None" % (vector_imp.getWidth(),vector_imp.getHeight(),vector_imp.getStackSize())) #Convert all images to RGB unregistered_merged_channels_imp = RGBStackMerge.mergeChannels([unregistered_tdTom_imp, unregistered_GC6s_imp, None],False) registered_merged_channels_imp = RGBStackMerge.mergeChannels([registered_tdTom_imp, registered_GC6s_imp, None],False) IJ.run(unregistered_merged_channels_imp, "RGB Color", "slices") IJ.run(registered_merged_channels_imp, "RGB Color", "slices") IJ.run(vector_imp, "RGB Color", "slices") #Combine image into one (stacked on top of each other) two_combined_stack = stack_combiner.combineVertically(unregistered_merged_channels_imp.getStack(), vector_imp.getStack()) three_combined_stack = stack_combiner.combineVertically(two_combined_stack, registered_merged_channels_imp.getStack()) #Save result file_saver_combined_image = FileSaver(ImagePlus('combined',three_combined_stack)) file_saver_combined_image.saveAsTiffStack(files['column_out']) + +##Calculate baseline average intensity +#n = unregistered_GC6s_imp.getStackSize() +#unregistered_GC6s_avg_imp = z_proj.run(unregistered_GC6s_imp,"avg") +#registered_GC6s_avg_imp = z_proj.run(registered_GC6s_imp,"avg") +#unregistered_tdTom_avg_imp = z_proj.run(unregistered_tdTom_imp,"avg") +#registered_tdTom_avg_imp = z_proj.run(registered_tdTom_imp,"avg") +# +#dF_imp = ic.run("Subtract create 32-bit stack", unregistered_GC6s_imp, unregistered_GC6s_avg_imp) +#dF_over_F_imp = ic.run("Divide create 32-bit stack", dF_imp,unregistered_GC6s_avg_imp) diff --git a/files.json b/files.json index 286e762..1847b01 100644 --- a/files.json +++ b/files.json @@ -1,16 +1,16 @@ { "output_dir": "/home/aymanns/Data_R57C10s/2_170608_fly1_007/results", "GC6s_input": "/home/aymanns/Data_R57C10s/2_170608_fly1_007/GC6s.tif", "tdTom_input": "/home/aymanns/Data_R57C10s/2_170608_fly1_007/tdTom.tif", - "slices_removed": "first=11 increment=1", + "slices_removed": "first=251 increment=1", "GC6s_registered": "/home/aymanns/Data_R57C10s/2_170608_fly1_007/results/warped1.tif", "tdTom_registered": "/home/aymanns/Data_R57C10s/2_170608_fly1_007/results/warped2.tif", "color_flow_out": "/home/aymanns/Data_R57C10s/2_170608_fly1_007/results/color_flow.tif", "vectors_out": "/home/aymanns/Data_R57C10s/2_170608_fly1_007/results/vectors.tif", "column_out": "/home/aymanns/Data_R57C10s/2_170608_fly1_007/results/column.tif" } diff --git a/files_1_170414_fly1_000.json b/files_1_170414_fly1_000.json new file mode 100644 index 0000000..b2d971e --- /dev/null +++ b/files_1_170414_fly1_000.json @@ -0,0 +1,16 @@ +{ + "output_dir": "/home/aymanns/Data_R57C10s/1_170414_fly1_000/results", + + "GC6s_input": "/home/aymanns/Data_R57C10s/1_170414_fly1_000/GC6s.tif", + "tdTom_input": "/home/aymanns/Data_R57C10s/1_170414_fly1_000/tdTom.tif", + + "slices_removed": "first=201 increment=1", + + "GC6s_registered": "/home/aymanns/Data_R57C10s/1_170414_fly1_000/results/warped1.tif", + "tdTom_registered": "/home/aymanns/Data_R57C10s/1_170414_fly1_000/results/warped2.tif", + + "color_flow_out": "/home/aymanns/Data_R57C10s/1_170414_fly1_000/results/color_flow.tif", + "vectors_out": "/home/aymanns/Data_R57C10s/1_170414_fly1_000/results/vectors.tif", + + "column_out": "/home/aymanns/Data_R57C10s/1_170414_fly1_000/results/column.tif" +} diff --git a/files.json b/files_2_170608_fly1_007.json similarity index 93% copy from files.json copy to files_2_170608_fly1_007.json index 286e762..8f47af3 100644 --- a/files.json +++ b/files_2_170608_fly1_007.json @@ -1,16 +1,16 @@ { "output_dir": "/home/aymanns/Data_R57C10s/2_170608_fly1_007/results", "GC6s_input": "/home/aymanns/Data_R57C10s/2_170608_fly1_007/GC6s.tif", "tdTom_input": "/home/aymanns/Data_R57C10s/2_170608_fly1_007/tdTom.tif", - "slices_removed": "first=11 increment=1", + "slices_removed": "first=201 increment=1", "GC6s_registered": "/home/aymanns/Data_R57C10s/2_170608_fly1_007/results/warped1.tif", "tdTom_registered": "/home/aymanns/Data_R57C10s/2_170608_fly1_007/results/warped2.tif", "color_flow_out": "/home/aymanns/Data_R57C10s/2_170608_fly1_007/results/color_flow.tif", "vectors_out": "/home/aymanns/Data_R57C10s/2_170608_fly1_007/results/vectors.tif", "column_out": "/home/aymanns/Data_R57C10s/2_170608_fly1_007/results/column.tif" } diff --git a/files_4_170609_fly1_000.json b/files_4_170609_fly1_000.json new file mode 100644 index 0000000..ab5690d --- /dev/null +++ b/files_4_170609_fly1_000.json @@ -0,0 +1,16 @@ +{ + "output_dir": "/home/aymanns/Data_R57C10s/4_170609_fly1_000/results", + + "GC6s_input": "/home/aymanns/Data_R57C10s/4_170609_fly1_000/GC6s.tif", + "tdTom_input": "/home/aymanns/Data_R57C10s/4_170609_fly1_000/tdTom.tif", + + "slices_removed": "first=201 increment=1", + + "GC6s_registered": "/home/aymanns/Data_R57C10s/4_170609_fly1_000/results/warped1.tif", + "tdTom_registered": "/home/aymanns/Data_R57C10s/4_170609_fly1_000/results/warped2.tif", + + "color_flow_out": "/home/aymanns/Data_R57C10s/4_170609_fly1_000/results/color_flow.tif", + "vectors_out": "/home/aymanns/Data_R57C10s/4_170609_fly1_000/results/vectors.tif", + + "column_out": "/home/aymanns/Data_R57C10s/4_170609_fly1_000/results/column.tif" +} diff --git a/histograms.py b/histograms.py new file mode 100644 index 0000000..bd32392 --- /dev/null +++ b/histograms.py @@ -0,0 +1,63 @@ +from matplotlib import pyplot as plt +from mpl_toolkits.mplot3d import Axes3D +import numpy as np +import glob + +path = '.' + +n_frames = int(len(glob.glob1(path,"*.dat"))/2) + +wx = np.genfromtxt('tmp201804201803wx_frame1.dat', delimiter=',') +wy = np.genfromtxt('tmp201804201803wy_frame1.dat', delimiter=',') + +wx2 = np.square(wx) +wy2 = np.square(wy) +l2 = wx2 + wy2 +l = np.sqrt(l2) + +lengths = np.empty([n_frames,wx.size]) +lengths[0,:] = l.flatten() + +for i in range(1,n_frames): + + wx = np.genfromtxt('tmp201804201803wx_frame{}.dat'.format(i+1), delimiter=',') + wy = np.genfromtxt('tmp201804201803wy_frame{}.dat'.format(i+1), delimiter=',') + + wx2 = np.square(wx) + wy2 = np.square(wy) + l2 = wx2 + wy2 + l = np.sqrt(l2) + lengths[i,:] = l.flatten() + +plt.figure() +plt.hist(lengths.flatten()) +plt.xlabel('Displacement [pixels]') +plt.ylabel('Frequency') +plt.show() + +plt.figure() +plt.hist2d(lengths.flatten(),np.repeat(range(1,n_frames+1),wx.size),bins=9) +plt.show() + +fig = plt.figure() +ax = fig.add_subplot(111, projection='3d') +hist, xedges, yedges = np.histogram2d(lengths.flatten(), np.repeat(range(1,n_frames+1),wx.size), bins=9, range=[[0, 50], [1, n_frames]]) +xpos, ypos = np.meshgrid(xedges[:-1], yedges[:-1]) +xpos = xpos.flatten('F') +ypos = ypos.flatten('F') +zpos = np.zeros_like(xpos) +dx = 2.5 * np.ones_like(zpos) +dy = (n_frames-1)/20*np.ones_like(zpos) +dz = hist.flatten() +ax.bar3d(xpos, ypos, zpos, dx, dy, dz, color='b', zsort='average') +plt.show() + +plt.figure() +max_lengths = np.amax(lengths, axis=1) +plt.hist(max_lengths) +plt.show() + +plt.figure() +mean_lengths = np.mean(lengths, axis=1) +plt.hist(mean_lengths) +plt.show() diff --git a/motion_compensate.m b/motion_compensate.m index ce6818b..f7a7468 100755 --- a/motion_compensate.m +++ b/motion_compensate.m @@ -1,77 +1,77 @@ function motion_compensate(fnInput1,fnInput2,fnMatch,fnDeepMatching,fnOut1,fnOut2,fnColor,fnVector,N,param) %% Description % Motion is estimated with a brigthness constancy data term defined on fnInput1 % and a feature matching similarity term defined on fnMatch. The sequences fnIput1 and % fnInput2 are warped according to the estimated motion field. % For more details see the paper: "Imaging neural activity in the ventral % nerve cord of behaving adult Drosophila", bioRxiv % %% Input % fnInput1: filename of the sequence used for the brightness constancy term, in TIF format % fnInput2: filename of the sequence warped with the motion field estimated from fnInput1 and fnMatch, in TIF format % fnMatch: filename of the sequence used for feature matching, in TIF format % fnDeepMatching: filename of the deepmatching code % fnOut1: filename used to save the warped version of fnInput1, in TIF format % fnOut2: filename used to save the warped version of fnInput2, in TIF format % fnOut2: filename used to save the color visualization of the estimated motion, in TIF format % N: number of frames to process % param: parameters of the algorithm (see 'default_parameters.m') % % Copyright (C) 2017 D. Fortun, denis.fortun@epfl.ch % % This program is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by % the Free Software Foundation, either version 3 of the License, or % (at your option) any later version. % % This program is distributed in the hope that it will be useful, % but WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % GNU General Public License for more details. %% Input data seq=mijread_stack(fnInput1); seqW=mijread_stack(fnInput2); seqMatch=mijread_stack(fnMatch); if N==-1 N=size(seq,3); end seq=double(seq(:,:,1:N)); seqRescale=(seq-min(seq(:)))/(max(seq(:))-min(seq(:)))*255; seqW=double(seqW(:,:,1:N)); seqMatch=double(seqMatch(:,:,1:N)); seqMatch=(seqMatch-min(seqMatch(:)))/(max(seqMatch(:))-min(seqMatch(:)))*255; % Motion estimation w=zeros(size(seqRescale,1),size(seqRescale,2),2,size(seqRescale,3)-1); colorFlow=zeros(size(seqRescale,1),size(seqRescale,2),3,size(seqRescale,3)-1); vectorFlow=zeros(512,512,size(seqRescale,3)-1); i1=seqRescale(:,:,1); i1Match=seqMatch(:,:,1); -parfor t=1:N-1 % Replace parfor by for if you don't want to parallelize +for t=1:N-1 % Replace parfor by for if you don't want to parallelize fprintf('Frame %i\n',t); i2=seqRescale(:,:,t+1); i2Match=seqMatch(:,:,t+1); [i10,i2]=midway(i1,i2); w(:,:,:,t) = compute_motion(i10,i2,i1Match,i2Match,fnDeepMatching,param,t); colorFlow(:,:,:,t)=flowToColor(w(:,:,:,t)); vectorFlow(:,:,t)=flowToVectorImage(w(:,:,:,t),15,[512,512],t); end %% Registration seqWarped=seq; seqwWarped=seqW; parfor t=1:N-1 seqWarped(:,:,t+1)=warpImg(seq(:,:,t+1),w(:,:,1,t),w(:,:,2,t)); seqwWarped(:,:,t+1)=warpImg(seqW(:,:,t+1),w(:,:,1,t),w(:,:,2,t)); end %% Save mijwrite_stack(single(seqWarped),fnOut1); mijwrite_stack(single(seqwWarped),fnOut2); mijwrite_stack(single(colorFlow),fnColor,1); mijwrite_stack(single(vectorFlow),fnVector); diff --git a/pipeline.run b/pipeline.run index 1803fad..8841b1d 100644 --- a/pipeline.run +++ b/pipeline.run @@ -1,16 +1,19 @@ #!/bin/bash +#SBATCH -p debug #SBATCH --workdir /home/aymanns/motion-correction-paper #SBATCH --nodes 1 #SBATCH --ntasks 1 #SBATCH --cpus-per-task 1 -#SBATCH --mem 64000 -#SBATCH --time 02:0:00 +#SBATCH --mem 128000 +#SBATCH --time 01:00:00 module load matlab module load jdk +module load gcc +module load openblas/0.2.19-openmp echo STARTING at `date` /home/aymanns/Fiji.app/ImageJ-linux64 --ij2 --headless --console --run /home/aymanns/motion-correction-paper/preprocessing.py 'parameter_file="files_4_170609_fly1_000.json"' echo FINISHED preprocessing at `date` matlab -nodesktop -nodisplay -r "test('files_4_170609_fly1_000.json')" echo FINISHED Matlab at `date` /home/aymanns/Fiji.app/ImageJ-linux64 --ij2 --headless --console --run /home/aymanns/motion-correction-paper/fiji_script_vertical_combination.py 'parameter_file="files_4_170609_fly1_000.json"' echo FINISHED Fiji at `date` diff --git a/pipeline.run b/pipeline2.run similarity index 65% copy from pipeline.run copy to pipeline2.run index 1803fad..abb7f4a 100644 --- a/pipeline.run +++ b/pipeline2.run @@ -1,16 +1,19 @@ #!/bin/bash +#SBATCH -p debug #SBATCH --workdir /home/aymanns/motion-correction-paper #SBATCH --nodes 1 #SBATCH --ntasks 1 #SBATCH --cpus-per-task 1 -#SBATCH --mem 64000 -#SBATCH --time 02:0:00 +#SBATCH --mem 128000 +#SBATCH --time 01:00:00 module load matlab module load jdk +module load gcc +module load openblas/0.2.19-openmp echo STARTING at `date` -/home/aymanns/Fiji.app/ImageJ-linux64 --ij2 --headless --console --run /home/aymanns/motion-correction-paper/preprocessing.py 'parameter_file="files_4_170609_fly1_000.json"' +/home/aymanns/Fiji.app/ImageJ-linux64 --ij2 --headless --console --run /home/aymanns/motion-correction-paper/preprocessing.py 'parameter_file="files_2_170608_fly1_007.json"' echo FINISHED preprocessing at `date` -matlab -nodesktop -nodisplay -r "test('files_4_170609_fly1_000.json')" +matlab -nodesktop -nodisplay -r "test('files_2_170608_fly1_007.json')" echo FINISHED Matlab at `date` -/home/aymanns/Fiji.app/ImageJ-linux64 --ij2 --headless --console --run /home/aymanns/motion-correction-paper/fiji_script_vertical_combination.py 'parameter_file="files_4_170609_fly1_000.json"' +/home/aymanns/Fiji.app/ImageJ-linux64 --ij2 --headless --console --run /home/aymanns/motion-correction-paper/fiji_script_vertical_combination.py 'parameter_file="files_2_170608_fly1_007.json"' echo FINISHED Fiji at `date` diff --git a/pipeline.run b/pipeline3.run similarity index 65% copy from pipeline.run copy to pipeline3.run index 1803fad..4c3fb10 100644 --- a/pipeline.run +++ b/pipeline3.run @@ -1,16 +1,19 @@ #!/bin/bash +#SBATCH -p debug #SBATCH --workdir /home/aymanns/motion-correction-paper #SBATCH --nodes 1 #SBATCH --ntasks 1 #SBATCH --cpus-per-task 1 -#SBATCH --mem 64000 -#SBATCH --time 02:0:00 +#SBATCH --mem 128000 +#SBATCH --time 01:00:00 module load matlab module load jdk +module load gcc +module load openblas/0.2.19-openmp echo STARTING at `date` -/home/aymanns/Fiji.app/ImageJ-linux64 --ij2 --headless --console --run /home/aymanns/motion-correction-paper/preprocessing.py 'parameter_file="files_4_170609_fly1_000.json"' +/home/aymanns/Fiji.app/ImageJ-linux64 --ij2 --headless --console --run /home/aymanns/motion-correction-paper/preprocessing.py 'parameter_file="files_1_170414_fly1_000.json"' echo FINISHED preprocessing at `date` -matlab -nodesktop -nodisplay -r "test('files_4_170609_fly1_000.json')" +matlab -nodesktop -nodisplay -r "test('files_1_170414_fly1_000.json')" echo FINISHED Matlab at `date` -/home/aymanns/Fiji.app/ImageJ-linux64 --ij2 --headless --console --run /home/aymanns/motion-correction-paper/fiji_script_vertical_combination.py 'parameter_file="files_4_170609_fly1_000.json"' +/home/aymanns/Fiji.app/ImageJ-linux64 --ij2 --headless --console --run /home/aymanns/motion-correction-paper/fiji_script_vertical_combination.py 'parameter_file="files_1_170414_fly1_000.json"' echo FINISHED Fiji at `date` diff --git a/test.m b/test.m index 8f74068..3973d45 100755 --- a/test.m +++ b/test.m @@ -1,54 +1,58 @@ function test(fname) +start_time = datestr(now,'yyyymmddHHMM'); +tmpdir = ['/scratch/aymanns/tmp',start_time]; +mkdir(tmpdir); + warn = warning ('off','all'); poolobj = gcp('nocreate'); if isempty(poolobj) parpool; end pctRunOnAll warning('off','all') %% set path fnIJ='/home/aymanns/registration/ij.jar'; % Path to "ij.jar" fnMIJ='/home/aymanns/registration/mij.jar'; % Path to "mij.jar" javaaddpath(fnIJ); javaaddpath(fnMIJ); addpath('code'); addpath('code/external/utils'); addpath(genpath('code/external/InvPbLib')); %% load file names %fname = 'files.json'; fid = fopen(fname); raw = fread(fid,inf); str = char(raw'); fclose(fid); files = parse_json(str); %% Parameters param = default_parameters(); param.lambda = 1000; % Regularization parameter param.gamma = 100; % Sets the strength of the feature matching constraint %% Input - Output type=1; % 0 for Mac users, 1 for Linux users fnMatch=files.tdTom_input;%'/home/aymanns/data/1_Horizontal_VNC/tdTom.tif'; % Sequence used for the feature matching similarity term fnIn1=[files.output_dir,'/GC6s_preprocessed.tif']; % Sequence used for the brightness constancy term fnIn2=[files.output_dir,'/tdTom_preprocessed.tif']; % Sequence warped with the motion field estimated from fnIn1 and fnMatch N=-1; % Motion is estimated on frames 1 to N. If N=-1, motion is estimated on % the whole sequence fnOut1=files.GC6s_registered; % Sequence fnIn1 warped fnOut2=files.tdTom_registered; % Sequence fnIn2 warped fnColor=files.color_flow_out; % Color visualization of the motion field fnVector=files.vectors_out; if type==0 fnDeepMatching='code/external/deepmatching_1.2.2_c++_mac'; elseif type==1 fnDeepMatching='code/external/deepmatching_1.2.2_c++_linux'; end addpath(fnDeepMatching); %% Perform motion compensation -motion_compensate(fnIn1,fnIn2,fnMatch,fnDeepMatching,fnOut1,fnOut2,fnColor,fnVector,N,param); +modified_motion_compensate(fnIn1,fnIn2,fnMatch,fnDeepMatching,fnOut1,fnOut2,fnColor,fnVector,N,param,tmpdir,files.output_dir); end