diff --git a/matlab/load_correlation_get_samples_neighbor.m b/matlab/load_correlation_get_samples_neighbor.m index c007e2b..403b945 100644 --- a/matlab/load_correlation_get_samples_neighbor.m +++ b/matlab/load_correlation_get_samples_neighbor.m @@ -54,35 +54,51 @@ nstims = 2002; end + +%% + +clear all; +clc; + +source_root='/media/nas/volume1/behavior/stimuli/pnas_morphs/V1features/pov2000_final/'; +% out_root='/nas/volume1/behavior/stimuli/pnas_morphs/samples/V1_euclid_neighbor/'; + +im_root='/media/nas/volume1/behavior/stimuli/pnas_morphs/POV/pov2000/final/'; + +base_root = '/media/nas/volume1/behavior/stimuli/pnas_morphs/samples/'; + + %% mfiles = dir([base_root,'*.mat']); matnames = cell(1, length(mfiles)); for i=1:length(mfiles) - if strfind(mfiles(i).name, sprintf('neighbor_%i', nstims)) + if strfind(mfiles(i).name, 'neighbor_') matnames{i} = mfiles(i).name; end end matnames = matnames(~cellfun('isempty', matnames)) -% +%% for f=1:length(matnames) f curr_mfile = matnames{f} load([base_root, curr_mfile]); - + D + parts = strsplit(curr_mfile, '_'); + sample_folder = strjoin(parts(1:end-1), '_') + out_root=[base_root, sample_folder, '/']; + % end % Get linearly-spaced samples nmorphs = 20; - if strfind(stimset, 'euclid') - cumsum_total = cumsum(distance_vect); - else - cumsum_total = cumsum(D.dist_vect); - end + + cumsum_total = cumsum(D.dist_vect); + start_point = cumsum_total(1); end_point = cumsum_total(end); lin_samples = linspace(start_point, end_point, nmorphs+2); @@ -126,12 +142,13 @@ dest = dest{1} copyfile(src, dest); end - + + D.sample_idxs = sample_idxs; + D.cumsum_total = cumsum_total; % Crap sampling due to nonlinear distances? Generally seems okay for neighbor comparisons (both euclid and pcorr) % only seems to be a problem for fixed-ref... - save([base_dir,matname], ... - 'cumsum_total', 'sample_idxs', '-append') + save([base_root,curr_mfile], 'D', '-append') end \ No newline at end of file diff --git a/matlab/sample_V1_features_euclid_fixedref.m b/matlab/sample_V1_features_euclid_fixedref.m index 15de364..8da65ce 100644 --- a/matlab/sample_V1_features_euclid_fixedref.m +++ b/matlab/sample_V1_features_euclid_fixedref.m @@ -91,51 +91,71 @@ % % so_true = check_vect==corr_vect; +%% Load .mat if exists to samlpe: + +mname = 'V1_euclid_fixedref_'; +base_root = '/media/nas/volume1/behavior/stimuli/pnas_morphs/samples/'; + +mfiles = dir([base_root,'*.mat']); + +matnames = cell(1, length(mfiles)); +for i=1:length(mfiles) + if strfind(mfiles(i).name, mname) + matnames{i} = mfiles(i).name; + end +end +matnames = matnames(~cellfun('isempty', matnames)) + +matname = matnames{1}; + +load([base_root, matname]); % This should load struct D + + %% Get linearly-spaced samples + +nmorphs = 20; +% lin_samples = linspace(min(distance_vect), max(distance_vect), nmorphs+2); % add 2 to account for anchors +lin_samples = linspace(D.dist_vect(1), D.dist_vect(end), nmorphs+2); + +sample_idxs = []; +for i=1:length(lin_samples) + [c index] = min(abs(D.dist_vect-lin_samples(i))) + sample_idxs = [sample_idxs; index]; +end + +% % and save them... % -% nmorphs = 20; -% % lin_samples = linspace(min(distance_vect), max(distance_vect), nmorphs+2); % add 2 to account for anchors -% lin_samples = linspace(D.dist_vect(1), D.dist_vect(end), nmorphs+2); -% -% sample_idxs = []; -% for i=1:length(lin_samples) -% [c index] = min(abs(D.dist_vect-lin_samples(i))) -% sample_idxs = [sample_idxs; index]; -% end -% -% % % and save them... -% % -% im_info = dir([im_root,'*.png']); -% im_names = cell(1, length(im_info)); -% for i=1:length(im_info) -% im_names{i} = im_info(i).name; -% end -% im_names = sort_nat(im_names); -% % -% -% if strfind(stimset, 'pov20') -% sample_idxs = linspace(1, nmorphs+2, nmorphs+2); -% end -% -% D.sample_idxs = sample_idxs; -% -% for i=1:length(sample_idxs) -% curr_sample_idx = sample_idxs(i); -% -% curr_sample = im_names(curr_sample_idx) -% src = strcat(im_root, curr_sample); -% src = src{1}; -% dest = strcat(out_root, curr_sample); -% dest = dest{1} -% copyfile(src, dest); -% end -% -% %% -% % CRAP SAMPLING due to non-linear changes: -% % sample_idxs = linspace(1, nmorphs+2, nmorphs+2); -% -% % save([base_dir,sprintf('V1features_euclid_fixedref_%s.mat', num2str(length(fnames)))], ... -% % 'sample_idxs', '-append') -% -% save([base_dir, matname], 'D', '-append') +im_info = dir([im_root,'*.png']); +im_names = cell(1, length(im_info)); +for i=1:length(im_info) + im_names{i} = im_info(i).name; +end +im_names = sort_nat(im_names); % + +if strfind(stimset, 'pov20') + sample_idxs = linspace(1, nmorphs+2, nmorphs+2); +end + +D.sample_idxs = sample_idxs; + +for i=1:length(sample_idxs) + curr_sample_idx = sample_idxs(i); + + curr_sample = im_names(curr_sample_idx) + src = strcat(im_root, curr_sample); + src = src{1}; + dest = strcat(out_root, curr_sample); + dest = dest{1} + copyfile(src, dest); +end + +%% +% CRAP SAMPLING due to non-linear changes: +% sample_idxs = linspace(1, nmorphs+2, nmorphs+2); + +% save([base_dir,sprintf('V1features_euclid_fixedref_%s.mat', num2str(length(fnames)))], ... +% 'sample_idxs', '-append') + +save([base_dir, matname], 'D', '-append') +