Module: JohnsonTbiLongitudinalSnodStats
- Defined in:
- lib/custom_methods/JohnsonTbiLongitudinalSnodStats.rb
Overview
require ‘logfile’
Constant Summary collapse
- DEFAULT_CONDITIONS =
[:new, :old]
Instance Method Summary collapse
- #create_or_link_onsets_files ⇒ Object
-
#run_first_level_stats ⇒ Object
(also: #perform)
runs the complete set of tasks using data in a subject’s “proc” directory and a preconfigured template spm job.
-
#run_stats_spm_job ⇒ Object
Finally runs the stats job.
- #setup_conditions ⇒ Object
- #setup_onsets ⇒ Object
Instance Method Details
#create_or_link_onsets_files ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/custom_methods/JohnsonTbiLongitudinalSnodStats.rb', line 29 def create_or_link_onsets_files if @onsetsfiles.nil? if @responses.nil? raise ScriptError, "Condition vectors cannot be created because neither log response files nor onsets mat files have been specified." else @onsetsfiles = create_onsets_files(@responses, conditions) end else link_onsets_files end end |
#run_first_level_stats ⇒ Object Also known as: perform
runs the complete set of tasks using data in a subject’s “proc” directory and a preconfigured template spm job.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/custom_methods/JohnsonTbiLongitudinalSnodStats.rb', line 7 def run_first_level_stats flash "Highway to the dangerzone..." setup_directory(@statsdir, "STATS") Dir.chdir(@statsdir) do link_files_from_proc_directory(File.join(@procdir, "sw*.nii"), File.join(@procdir, "rp*.txt")) setup_onsets run_stats_spm_job end end |
#run_stats_spm_job ⇒ Object
Finally runs the stats job
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/custom_methods/JohnsonTbiLongitudinalSnodStats.rb', line 42 def run_stats_spm_job images = @scan_labels ? @scan_labels.collect! { |label| Dir.glob("sw*#{label}*.nii").to_s } : Dir.glob(File.join(@origdir, "sw*#{@subid}*.nii")) raise ScriptError, "Can't find any smoothed, warped images in #{@statsdir}" if images.empty? unless @onsetsfiles.length == @regressorsfiles.length && @regressorsfiles.length == @bold_reps.length raise ScriptError, "Mismatch between #{@bold_reps.length} reps, #{@onsetsfiles.length} onsets and #{@regressorsfiles.length} regressors files." end queue = MatlabQueue.new queue.paths << [ '/Applications/spm/spm8/spm8_current', '/apps/spm/spm8_current', File.join(@libdir, 'custom_methods'), File.join(@libdir, 'matlab_helpers') ] queue << "JohnsonTbiLongitudinalSnodStats('#{@statsdir}/', \ { #{images.collect {|im| "'#{File.basename(im)}'"}.join(' ')} }, \ { #{@bold_reps.join(' ') } }, \ { #{@onsetsfiles.collect { |file| "'#{File.basename(file)}'"}.join(' ') } }, \ { #{@regressorsfiles.collect { |file| "'#{File.basename(file)}'"}.join(' ') } }, \ 'JohnsonTbiLongitudinalSnodStats_job.m')" # puts queue.to_s queue.run! end |
#setup_conditions ⇒ Object
25 26 27 |
# File 'lib/custom_methods/JohnsonTbiLongitudinalSnodStats.rb', line 25 def setup_conditions @conditions = @conditions ? @conditions.collect {|c| c.to_sym if c.respond_to? :to_sym } : DEFAULT_CONDITIONS end |
#setup_onsets ⇒ Object
20 21 22 23 |
# File 'lib/custom_methods/JohnsonTbiLongitudinalSnodStats.rb', line 20 def setup_onsets setup_conditions create_or_link_onsets_files end |