% creates mask files for plotting in Amira load GeometryProstate.mat; % geometry file of interest amira_folder = 'amira2'; % folder for Amira data amira_file = 'prostateBoost.hx'; curr_dir = pwd; % current directory mkdir(amira_folder); % create the amira folder cd(amira_folder); % go to amira folder Nroi = length(Geometry.ROIS); % get number of ROIS from Geometry structure % icon position vectors xIcon = [0:2]*200 + 50; yIcon = [0:1]*50; yShift = [0:Nroi]*120 + 400; % get the names of the rois roi_names = cell(1,Nroi); for k=1:Nroi roi_names{k} = Geometry.ROIS{k}.name; end % set up a mask structure mask.start = Geometry.start; mask.voxel_size = Geometry.voxel_size; siz = size(Geometry.data); % mask dimensions % create the Amira .hx file fid = fopen(amira_file,'w'); fprintf(fid,'# Amira Script\n'); fprintf(fid,'remove -all\n'); fprintf(fid,['remove physics.icol glow.col dose.am BoundingBox OrthoSlice0 OrthoSlice1 OrthoSlice2 Colorwash0 Colorwash1 Colorwash2 Isolines0 Isolines1 Isolines2 GlobalAxis CastField\n']); fprintf(fid,'\n'); % viewer parameters fprintf(fid,'# Create viewers\n'); fprintf(fid,'viewer setVertical 0\n'); fprintf(fid,'\n'); fprintf(fid,'viewer 0 setBackgroundMode 1\n'); fprintf(fid,'viewer 0 setBackgroundColor 0.06 0.13 0.24\n'); fprintf(fid,'viewer 0 setBackgroundColor2 0.72 0.72 0.78\n'); fprintf(fid,'viewer 0 setTransparencyType 5\n'); fprintf(fid,'viewer 0 setAutoRedraw 0\n'); fprintf(fid,'viewer 0 show\n'); fprintf(fid,'mainWindow show\n'); fprintf(fid,'\n'); % create files for each mask region for k=1:Nroi mask_filename = [roi_names{k} '.am']; mask_filename = regexprep(mask_filename,' ',''); % remove spaces mask.data = zeros(siz,'int8'); mask.data(Geometry.ROIS{k}.ind) = 1; % fill in the mask geom2am(mask,mask_filename); % save the structure to an Amira file fprintf(fid,'set hideNewModules 0\n'); fprintf(fid,['[ load ${SCRIPTDIR}/' mask_filename ' ] setLabel ' mask_filename '\n']); fprintf(fid,[mask_filename ' setIconPosition ' num2str(xIcon(1)) ' ' num2str(yIcon(1)+yShift(k)) '\n']); fprintf(fid,[mask_filename ' fire\n']); fprintf(fid,[mask_filename ' fire\n']); fprintf(fid,[mask_filename ' setViewerMask 65535\n']); fprintf(fid,'\n'); % set up a CastField module for a LabelField for the mask fprintf(fid,'set hideNewModules 0\n'); castFieldName = ['CastField' num2str(k)]; fprintf(fid,['create HxCastField {' castFieldName '}\n']); fprintf(fid,[castFieldName ' setIconPosition ' num2str(xIcon(2)) ' ' num2str(yIcon(1)+yShift(k)) '\n']); fprintf(fid,[castFieldName ' data connect ' mask_filename '\n']); fprintf(fid,[castFieldName ' colormap setDefaultColor 1 0.8 0.5\n']); fprintf(fid,[castFieldName ' colormap setDefaultAlpha 0.500000\n']); fprintf(fid,[castFieldName ' fire\n']); fprintf(fid,[castFieldName ' outputType setValue 0 6\n']); fprintf(fid,[castFieldName ' scaling setMinMax 0 -1.00000001384843e+024 1.00000001384843e+024\n']); fprintf(fid,[castFieldName ' scaling setValue 0 1\n']); fprintf(fid,[castFieldName ' scaling setMinMax 1 -1.00000001384843e+024 1.00000001384843e+024\n']); fprintf(fid,[castFieldName ' scaling setValue 1 0\n']); fprintf(fid,[castFieldName ' voxelGridOptions setValue 0 1\n']); fprintf(fid,[castFieldName ' colorFieldOptions setValue 0 0\n']); fprintf(fid,[castFieldName ' fire\n']); fprintf(fid,[castFieldName ' setViewerMask 65535\n']); fprintf(fid,[castFieldName ' deselect\n']); fprintf(fid,'\n'); % set up mask plotting routines mask_labelfield_name = regexprep(mask_filename,'am','Labelfield'); fprintf(fid,'set hideNewModules 0\n'); fprintf(fid,['[ {' castFieldName '} create\n']); fprintf(fid,[' ] setLabel {' mask_labelfield_name '}\n']); fprintf(fid,[mask_labelfield_name ' setIconPosition ' num2str(xIcon(1)) ' ' num2str(yIcon(2)+yShift(k)) '\n']); fprintf(fid,[mask_labelfield_name ' master connect ' castFieldName '\n']); fprintf(fid,[mask_labelfield_name ' fire\n']); fprintf(fid,[mask_labelfield_name ' primary setValue 0 0\n']); fprintf(fid,[mask_labelfield_name ' fire\n']); fprintf(fid,[mask_labelfield_name ' setViewerMask 65535\n']); fprintf(fid,'\n'); surfaceGenName = ['SurfaceGen' num2str(k)]; fprintf(fid,'set hideNewModules 0\n'); fprintf(fid,['create HxGMC {' surfaceGenName '}\n']); fprintf(fid,[surfaceGenName ' setIconPosition ' num2str(xIcon(3)) ' ' num2str(yIcon(1)+yShift(k)) '\n']); fprintf(fid,[surfaceGenName ' data connect ' mask_labelfield_name '\n']); fprintf(fid,[surfaceGenName ' fire\n']); fprintf(fid,[surfaceGenName ' smoothing setValue 0 3\n']); fprintf(fid,[surfaceGenName ' options setValue 0 1\n']); fprintf(fid,[surfaceGenName ' options setValue 1 0\n']); fprintf(fid,[surfaceGenName ' border setValue 0 1\n']); fprintf(fid,[surfaceGenName ' border setValue 1 0\n']); fprintf(fid,[surfaceGenName ' minEdgeLength setMinMax 0 0 0.800000011920929\n']); fprintf(fid,[surfaceGenName ' minEdgeLength setValue 0 0\n']); fprintf(fid,[surfaceGenName ' materialList setValue 0 0\n']); fprintf(fid,[surfaceGenName ' fire\n']); fprintf(fid,[surfaceGenName ' setViewerMask 65535\n']); fprintf(fid,'\n'); mask_surf_name = regexprep(mask_filename,'am','surf'); fprintf(fid,'set hideNewModules 0\n'); fprintf(fid,['[ {' surfaceGenName '} create {' mask_surf_name '}\n']); fprintf(fid,[' ] setLabel {' mask_surf_name '}\n']); fprintf(fid,[mask_surf_name ' setIconPosition ' num2str(xIcon(2)) ' ' num2str(yIcon(2)+yShift(k)) '\n']); fprintf(fid,[mask_surf_name ' master connect ' surfaceGenName '\n']); fprintf(fid,[mask_surf_name ' fire\n']); fprintf(fid,[mask_surf_name ' LevelOfDetail setMinMax -1 -1\n']); fprintf(fid,[mask_surf_name ' LevelOfDetail setButtons 1\n']); fprintf(fid,[mask_surf_name ' LevelOfDetail setIncrement 1\n']); fprintf(fid,[mask_surf_name ' LevelOfDetail setValue -1\n']); fprintf(fid,[mask_surf_name ' LevelOfDetail setSubMinMax -1 -1\n']); fprintf(fid,[mask_surf_name ' fire\n']); fprintf(fid,[mask_surf_name ' setViewerMask 65535\n']); fprintf(fid,[mask_surf_name ' deselect\n']); fprintf(fid,'\n'); fprintf(fid,'set hideNewModules 0\n'); fprintf(fid,'\n'); surfaceViewName = ['SurfaceView' num2str(k)]; fprintf(fid,'set hideNewModules 0\n'); fprintf(fid,['create HxDisplaySurface {' surfaceViewName '}\n']); fprintf(fid,[surfaceViewName ' setIconPosition ' num2str(xIcon(3)) ' ' num2str(yIcon(2)+yShift(k)) '\n']); fprintf(fid,[surfaceViewName ' data connect ' mask_surf_name '\n']); fprintf(fid,[surfaceViewName ' colormap setDefaultColor 1 0.1 0.1\n']); fprintf(fid,[surfaceViewName ' colormap setDefaultAlpha 0.500000\n']); fprintf(fid,[surfaceViewName ' fire\n']); fprintf(fid,[surfaceViewName ' drawStyle setValue 4\n']); fprintf(fid,[surfaceViewName ' drawStyle setSpecularLighting 1\n']); fprintf(fid,[surfaceViewName ' drawStyle setTexture 0\n']); fprintf(fid,[surfaceViewName ' drawStyle setAlphaMode 3\n']); fprintf(fid,[surfaceViewName ' drawStyle setNormalBinding 0\n']); fprintf(fid,[surfaceViewName ' drawStyle setCullingMode 0\n']); fprintf(fid,[surfaceViewName ' selectionMode setValue 0 0\n']); fprintf(fid,[surfaceViewName ' Patch setMinMax 0 1\n']); fprintf(fid,[surfaceViewName ' Patch setButtons 1\n']); fprintf(fid,[surfaceViewName ' Patch setIncrement 1\n']); fprintf(fid,[surfaceViewName ' Patch setValue 1\n']); fprintf(fid,[surfaceViewName ' Patch setSubMinMax 0 1\n']); fprintf(fid,[surfaceViewName ' BoundaryId setValue 0 -1\n']); fprintf(fid,[surfaceViewName ' materials setValue 0 1\n']); fprintf(fid,[surfaceViewName ' materials setValue 1 0\n']); fprintf(fid,[surfaceViewName ' colorMode setValue 0\n']); fprintf(fid,[surfaceViewName ' baseTrans setMinMax 0 1\n']); fprintf(fid,[surfaceViewName ' baseTrans setButtons 0\n']); fprintf(fid,[surfaceViewName ' baseTrans setIncrement 0.1\n']); fprintf(fid,[surfaceViewName ' baseTrans setValue 0.53\n']); fprintf(fid,[surfaceViewName ' baseTrans setSubMinMax 0 1\n']); fprintf(fid,[surfaceViewName ' VRMode setValue 0 0\n']); fprintf(fid,[surfaceViewName ' fire\n']); fprintf(fid,[surfaceViewName ' hideBox 1\n']); fprintf(fid,['{' surfaceViewName '} selectTriangles zab HIJMPLPPHPGAABDPBAADAACGHIICIN\n']); fprintf(fid,[surfaceViewName ' fire\n']); fprintf(fid,[surfaceViewName ' setViewerMask 65535\n']); fprintf(fid,[surfaceViewName ' deselect\n']); fprintf(fid,'\n'); end fclose(fid);