Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions schemas/+psy/MovieClipStore.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
%{
psy.MovieClipStore (imported) # clips from movies
-> psy.MovieInfo
clip_number : int # clip index
-----
file_name : varchar(255) # full file name
clip : longblob #
%}


classdef MovieClipStore < dj.Relvar & dj.AutoPopulate
properties
popRel = psy.MovieInfo
end

methods (Access=protected)
function makeTuples(self,key)
[path,file_temp] = fetch1(psy.MovieInfo & key,'path','file_template');
clips = dir(fullfile(getLocalPath(path),['*.' file_temp(end-2:end)]));
for iclip = 1:length(clips);
clip_number = sscanf(clips(iclip).name,file_temp);
if isempty(clip_number);continue;end
tuple = key;
tuple.clip_number = clip_number;
tuple.file_name = clips(iclip).name;
fid = fopen(getLocalPath(fullfile(path,tuple.file_name)));
tuple.clip = fread(fid,'*int8');
fclose(fid);
self.insert(tuple)
end
end
end

methods
function filenames = export(obj)

[file_names,clips] = fetchn(obj,'file_name','clip');
path = getLocalPath(fetch1(psy.MovieInfo & obj,'path'));
if ~exist(path,'dir');mkdir(path);end

filenames = cell(length(file_names),1);
for ifile = 1:length(file_names)
filenames{ifile} = fullfile(path,file_names{ifile});
if exist(filenames{ifile}, 'file');delete(filenames{ifile});end
fid = fopen(filenames{ifile},'w');
fwrite(fid,clips{ifile},'int8');
fclose(fid);
end

if length(filenames)==1; filenames = filenames{1};end

end
end
end
5 changes: 3 additions & 2 deletions schemas/+psy/MovieInfo.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
movie_name : char(8) # short movie title
-----
movie_title : varchar(255) # full movie title
path_template : varchar(255) # filename template with full path
path : varchar(255) # path for movies
file_template : varchar(255) # filename template with full path
file_duration : float # (s) duration of each file (must be equal)
frame_rate : float # frames per second
frame_width : int # (pixels)
Expand All @@ -15,7 +16,7 @@
methods
function fill(self)
self.inserti({
'MadMax' 'Mad Max: Fury Road (2015)' '~/stimuli/movies/madmax/madmax_%03u.avi' 60 30 255 144
'MadMax' 'Mad Max: Fury Road (2015)' '~/stimuli/movies' 'madmax_%03u.avi' 60 30 255 144
})
end
end
Expand Down