def output_maps(self, nifti_filepath, threshold=0.01, two_tail=True, threshold_type="pvalue"): print "Normalizing X matrix..." Xnorm = simple_normalize(self.data.X) print "Classifying with linear svm..." clf = self.fit_linearsvc(Xnorm, self.data.Y) print "Thresholding and dumping coefficients to file..." self.coefs = clf.coef_[0] if threshold_type == "pvalue": thresholded_coefs = threshold_by_pvalue(self.coefs, threshold, two_tail=two_tail) elif threshold_type == "raw_percentage": thresholded_coefs = threshold_by_rawrange(self.coefs, threshold, two_tail=two_tail) self.nifti.output_nifti_thrumask( thresholded_coefs, self.data.trial_mask, self.data.mask_shape, len(self.data.selected_trs), self.data.raw_affine, nifti_filepath, ) self.nifti.convert_to_afni(nifti_filepath, nifti_filepath[:-4]) self.nifti.adwarp_to_template_talairach( nifti_filepath[:-4] + "+orig", None, self.data.talairach_template_path, self.data.dxyz, overwrite=True )
def output_maps(self, X, Y, time_points, nifti_filepath, threshold=0.01, two_tail=True, verbose=True): if not nifti_filepath.endswith('.nii'): nifti_filepath = nifti_filepath+'.nii' if verbose: print 'fitting to output...' clf = self.fit_linearsvc(X, Y) self.coefs = clf.coef_[0] thresholded_coefs = threshold_by_pvalue(self.coefs, threshold, two_tail=two_tail) if verbose: print 'reshaping the coefs to original brain shape...' unmasked = self.data.unmask_Xcoefs(thresholded_coefs, time_points, verbose=verbose) if verbose: print 'saving nifti to filename:', nifti_filepath self.data.save_unmasked_coefs(unmasked, nifti_filepath)
def output_maps(self, X, Y, time_points, nifti_filepath, threshold=0.01, two_tail=True, verbose=True): if not nifti_filepath.endswith('.nii'): nifti_filepath = nifti_filepath+'.nii' if verbose: print 'fitting prior to output...' pls = self.pls_train(X, Y, verbose=verbose) coefs = pls.coefs thresh_coefs = threshold_by_pvalue(coefs, threshold, two_tail=two_tail) if verbose: print 'reshaping the coefs to the original brain shape...' unmasked = self.data.unmask_Xcoefs(thresh_coefs, time_points, verbose=verbose) if verbose: print 'saving nifti to filename: ', nifti_filepath self.data.save_unmasked_coefs(unmasked, nifti_filepath)