diff --git a/antrax/classifier.py b/antrax/classifier.py index 2555bec..19fe5fc 100644 --- a/antrax/classifier.py +++ b/antrax/classifier.py @@ -336,6 +336,8 @@ def predict_images_file(self, imagefile, outfile=None, usepassed=False, report=F names += [tracklet] + f.close() + if outfile is None: outfile = os.path.join(self.outdir, 'autoids_' + str(m) + '.csv') diff --git a/antrax/cli.py b/antrax/cli.py index 0e5d624..7cf8c6e 100755 --- a/antrax/cli.py +++ b/antrax/cli.py @@ -377,7 +377,7 @@ def solve(explist, *, glist: parse_movlist=None, movlist: parse_movlist=None, cl def train(classdir, *, name='classifier', scratch=False, ne=5, unknown_weight=20, multi_weight=0.1, arch='small', modelfile=None, target_size: to_int=None, crop_size: to_int=None, hsymmetry=False, aug_options='', hpc=False, hpc_options: parse_hpc_options={}, - dry=False): + background='white', dry=False): """Train a blob classifier""" hpc = hpc or ANTRAX_HPC @@ -402,7 +402,7 @@ def train(classdir, *, name='classifier', scratch=False, ne=5, unknown_weight=2 f = glob(examplesdir + '/*/*.png')[0] target_size = max(imread(f).shape) - c = axClassifier(name, nclasses=n, target_size=target_size, crop_size=crop_size, hsymmetry=hsymmetry, + c = axClassifier(name, nclasses=n, target_size=target_size, crop_size=crop_size, hsymmetry=hsymmetry, background=background, unknown_weight=unknown_weight, multi_weight=multi_weight, modeltype=arch, json=modelfile) c.save(classfile) diff --git a/bin/antrax_maci64_mcr_interface.app/Contents/MacOS/antrax_maci64_mcr_interface b/bin/antrax_maci64_mcr_interface.app/Contents/MacOS/antrax_maci64_mcr_interface index c2782c7..3adb82c 100755 Binary files a/bin/antrax_maci64_mcr_interface.app/Contents/MacOS/antrax_maci64_mcr_interface and b/bin/antrax_maci64_mcr_interface.app/Contents/MacOS/antrax_maci64_mcr_interface differ diff --git a/matlab/@tracklet/add_examples.m b/matlab/@tracklet/add_examples.m index f926b0e..857b302 100644 --- a/matlab/@tracklet/add_examples.m +++ b/matlab/@tracklet/add_examples.m @@ -41,7 +41,12 @@ function add_examples(trj,varargin) ims = trj.get_image(tt); msk = repmat(max(ims,[],3)==0,[1,1,3,1]); -ims(msk)=255; + +if trj.Trck.get_param('segmentation_invert') + ims(msk)=0; +else + ims(msk)=255; +end for i=1:size(ims,4) diff --git a/matlab/@trhandles/default_params.m b/matlab/@trhandles/default_params.m index 8aed6a6..79c916a 100644 --- a/matlab/@trhandles/default_params.m +++ b/matlab/@trhandles/default_params.m @@ -51,6 +51,7 @@ prmtrs.segmentation_illum_correct = false; prmtrs.segmentation_illum_correct_level = 0.9; +prmtrs.segmentation_invert = false; prmtrs.segmentation_threshold = 0.14; prmtrs.segmentation_IntensityFilter = false; diff --git a/matlab/apps/antrax.mlapp b/matlab/apps/antrax.mlapp index e88fbe9..754f155 100644 Binary files a/matlab/apps/antrax.mlapp and b/matlab/apps/antrax.mlapp differ diff --git a/matlab/apps/validate_classifications.mlapp b/matlab/apps/validate_classifications.mlapp index 09339d4..fdff3b2 100644 Binary files a/matlab/apps/validate_classifications.mlapp and b/matlab/apps/validate_classifications.mlapp differ diff --git a/matlab/misc/applyMasktoIm.m b/matlab/misc/applyMasktoIm.m index e9261c9..d1571f7 100644 --- a/matlab/misc/applyMasktoIm.m +++ b/matlab/misc/applyMasktoIm.m @@ -1,4 +1,4 @@ -function MaskedIm = applyMasktoIm(Im,Mask) +function MaskedIm = applyMasktoIm(Im,Mask,fillval) % jonathan saragosti % 02/18/15 % apply a binary mask to an image, diff --git a/matlab/misc/create_backgrounds.m b/matlab/misc/create_backgrounds.m index a8f997f..3642f45 100644 --- a/matlab/misc/create_backgrounds.m +++ b/matlab/misc/create_backgrounds.m @@ -85,6 +85,8 @@ function create_backgrounds(Trck, pb) switch method case 'max' bg = max(frames,[],4); + case 'min' + bg = min(frames,[],4); case 'median' bg = median(frames,4); otherwise diff --git a/matlab/tracking/detect_blobs.m b/matlab/tracking/detect_blobs.m index 776b9c6..d04bb88 100644 --- a/matlab/tracking/detect_blobs.m +++ b/matlab/tracking/detect_blobs.m @@ -52,8 +52,14 @@ function detect_blobs(Trck,varargin) %% Image segmentation -Z = imsubtract(BGS,frame_single); +if Trck.get_param('segmentation_invert') + Z = imsubtract(frame_single,BGS); +else + Z = imsubtract(BGS,frame_single); +end + Z = Z.*single(mask); + %Z = applyMasktoIm(Z,mask); if Trck.get_param('segmentation_local_z_scaling') @@ -69,7 +75,11 @@ function detect_blobs(Trck,varargin) % threshold the image if Trck.get_param('segmentation_use_max_rgb') ZGRY = max(Z,[],3); - FGRY = min(frame,[],3); + if Trck.get_param('segmentation_invert') + FGRY = max(frame,[],3); + else + FGRY = min(frame,[],3); + end else ZGRY = rgb2gray(Z); FGRY = rgb2gray(frame); @@ -223,7 +233,7 @@ function detect_blobs(Trck,varargin) sqsz = Trck.get_param('sqsz'); padded_label = padarray(ab.LABEL,[sqsz/2,sqsz/2]); -if Trck.get_param('segmentation_color_correction_for_classification') +if Trck.get_param('segmentation_color_correction_for_classification') && ~Trck.get_param('segmentation_invert') padded_frame = padarray(frame_corrected,[sqsz/2,sqsz/2]); else padded_frame = padarray(frame_orig,[sqsz/2,sqsz/2]); diff --git a/scripts/classifier_test_jobfile.sh b/scripts/classifier_test_jobfile.sh index 7f03414..abf1d5f 100644 --- a/scripts/classifier_test_jobfile.sh +++ b/scripts/classifier_test_jobfile.sh @@ -1,11 +1,16 @@ #!/bin/bash #SBATCH --job-name=ctest -#SBATCH --output=/ru-auth/local/home/agal/ctest1_%a.log +#SBATCH --output=/ru-auth/local/home/agal/logs/class_test_NAME__%a.log #SBATCH --ntasks=1 #SBATCH --cpus-per-task=8 #SBATCH --mail-type=ALL #SBATCH --mail-user=agal@rockefeller.edu -#SBATCH --array=0-50%100 +#SBATCH --array=1-NREP_%100 +NAME="NAME_" +N="N_" +LOG="LOG_" +CLASSDIR="CLASSDIR_" +NE="NE_" -srun python /ru-auth/local/home/agal/code/anTraX/scripts/classifier_test.py /ru-auth/local/home/agal/scratch/Classifiers/A36_classifier_analysis -n 2000 --name n2000 --ne 100 --logfile /ru-auth/local/home/agal/classifier_test.log \ No newline at end of file +srun python /ru-auth/local/home/agal/code/anTraX/scripts/classifier_test.py $CLASSDIR -n $N --name $NAME --ne $NE --logfile $LOGFILE \ No newline at end of file