.raw file in Paraview - dataset

I have downloaded a .raw datafile that I want to view in Paraview.
The dataset I'm using is taken from:
http://volvis.org/ -> download dataset -> CT Scan of bonsaitree.
Whenever I import the dataset I do as explained here in this link:
http://www.paraview.org/Wiki/ParaView/Data_formats#Raw_files
Everything goes fine until I hit apply. I then get these two error messages, and the view is empty:
ERROR: In C:\DBD\pvs-x64\paraview\src\paraview\ParaViewCore\VTKExtensions\Rendering\vtkTexturePainter.cxx, line 295
vtkTexturePainter (00000000136105F0): Incorrect dimensionality.
Warning: In C:\DBD\pvs-x64\paraview\src\paraview\VTK\Rendering\Core\vtkRenderer.cxx, line 1030
vtkOpenGLRenderer (0000000009CF08C0): Resetting view-up since view plane normal is parallel
How do I get rid of these error messages?

A raw file does not have a header with information about the data inside (orientation, dimension...). You have to provide that information, and it has to be compatible with the content of the image. I tried a couple of time with the data you provided and succeeded with the following parameters:
when prompted reader: raw binary file (I just checked the file content with notepad)
data extent: 0 255 0 255 0 255 (the website says that the image is 256x256x256)
data scalar type: char (I confess that I just guessed it at the first time, a more correct way would be to multiply the data type by the number of voxels and compare it with the file dimension).

Related

How to convert a .dm3 file (with annotation and scale bar) to .jpg/jpeg image?

I wonder how to convert a dm3 file into .jpg/jpeg images? there is test annotation and scale bar on the image. I setup a script but it always show that "the format cannot contain the data to be saved". This can be done via file/batch convert function. So how to realize the same function in script? Thanks
image test:=IntegerImage("test",2,1,100,100)
test.ShowImage()
image frontimage:=GetFrontImage()
string filename=getname(frontimage)
imagedisplay disp = frontImage.ImageGetImageDisplay(0)
disp.applydatabar()
ImageDocument frontDoc = GetFrontImageDocument()
string directoryname, pathname
number length
if(!SaveAsDialog("","Do Not Change Me",directoryname)) exit(0)
length=len(directoryname)-16
directoryname=mid(directoryname,0,length)
pathname=directoryname+filename
frontDoc.ImageDocumentSaveToFile( "JPG Format", pathname )
To convert to jpg you have to use "JPEG/JFIF Format" as the handler (=format).
It has to be exactly this string in the ImageDocument.ImageDocumentSaveToFile() function. Other formats are mentioned in the help (F1 > Scripting > Objects > Document Object Model > ImageDocument Object > ImageDocumentSaveToFile() function). Those are (for example):
'Gatan Format'
'Gatan 3 Format'
'GIF Format'
'BMP Format'
'JPEG/JFIF Format'
'Enhanced Metafile Format'
In your code you are using the SaveAsDialog() to get a directory. This is not necessary. You can use GetDirectoryDialog() to get a directory. This saves you the name operation for the directoryname and avoids problems when users do change your filename.
Also for concatinating paths I prefer using PathConcatenate(). On the first hand this makes your code a lot more readable since its name tells what you are doing. On the other hand this also takes care of the directory ending with \ or not and other path related things.
The following code is what I think you need:
Image test := IntegerImage("test", 2, 1, 100, 100);
test.ShowImage();
Image frontimage := GetFrontImage();
ImageDisplay disp = frontImage.ImageGetImageDisplay(0);
disp.applydatabar();
ImageDocument frontDoc = GetFrontImageDocument();
string directoryname;
if(!GetDirectoryDialog("Select directory", "C:\\\\", directoryname)){
// ↑
// You can of course use something else as the start point for selection here
exit(0);
}
string filename = GetName(frontimage);
string pathname = directoryname.PathConcatenate(filename);
frontDoc.ImageDocumentSaveToFile("JPEG/JFIF Format", pathname);
This answer is correct and should be accepted. Your problem is the wrong file-type string. You want to use "JPEG/JFIF Format"
A bit more general information on image file saving in DigitalMicrograph.
One doesn't save images but always imageDocuments that can contain one, more, or even zero image objects in them. Script-commands that save an image like SaveAsGatan() really just call things like: ImageGetOrCreateImageDocument().ImageDocumentSaveToFile()
The difference doesn't really matter for simple one-image-in-document type images, but it can make a difference when there are multiple images in a document, or when a single image is displayed multiple times simultaneously (which can be done.) So it is always good to know what "really" goes on.
ImageDocuments contain some properties relating to saving:
A save format (“Gatan Format”, “TIFF Format”, …)
Default value: What it was opened with, or last used save-format in case of creation
Script commands: ImageDocumentGetCurrentFileSaveFormat() ImageDocumentSetCurrentFileSaveFormat()
A current file path:
Default value: What it was opened from, or empty
Script commands: ImageDocumentGetCurrentFile() ImageDocumentSetCurrentFile()
A dirty-state:
Default value: clean when opened, dirty when created
Script commands: ImageDocumentIsDirty() ImageDocumentClean()
A linked-to-file state:
Default value: true when opened, false when created
Script commands: ImageDocumentIsLinkedToFile()
There are two ways of saving an imageDocument:
Saving the current document itself to disc:
void ImageDocumentSave( ImageDocument imgDoc, Number save_style ) This utilizes the current properties of the imageDocument to save it to current path in current format, marking it clean in the process. The save_style parameter determines how the program deals with missing info:
0 = never ask for path
1 = ask if not linked (or empty path)
2 = always ask
Saving a copy of the current document to disc:
void ImageDocumentSaveToFile( ImageDocument imgDoc, String handler, String fileName ) This makes a copy and save the file under provided path in the provided format. The imageDocument in memory does not change its properties. Most noticeable: It does not become clean, and it is not linked to the provided file on disc. The filename parameter specifies the saving location including the filename. If a file extension is provided, it has to match the file-format, but it can be left out. The handler parameter specified the file-format and can be anything GMS currently supports, such as:
Gatan Format
Gatan 3 Format
GIF Format
BMP Format
JPEG/JFIF Format
Enhanced Metafile Format
In short:
To save the currently opened imageDocument with a different format, you would want to do:
imageDocument doc = GetFrontImageDocument()
doc.ImageDocumentSetCurrentFileSaveFormat("TIFF Format")
doc.ImageDocumentSave(0)
While to just save a copy of the current state you would use:
imageDocument doc = GetFrontImageDocument()
string path = doc.ImageDocumentGetCurrentFile() // full path including extension!
path = PathExtractDirectory(path,0) + PathExtractBaseName(path,0) // path without file extension
doc.ImageDocumentSaveToFile("TIFF Format", path )

How to visualize LabelMe database using Matlab

The LabelMe database can be downloaded from http://www.cs.toronto.edu/~norouzi/research/mlh/data/LabelMe_gist.mat
However, there is another link http://labelme.csail.mit.edu/Release3.0/
The webpage has a toolbox but I could not find any database to download. So, I was wondering if I could use the LabelMe_gist.mat which has the following fields. The field names contins the labels for the images, and img perhaps contains the images. How do I display the training and test images? I tried
im = imread(img)
Error using imread>parse_inputs (line 486)
The filename or url argument must be a string.
Error in imread (line 336)
[filename, fmt_s, extraArgs, msg] = parse_inputs(varargin{:});
but surely this is not the way. Please help
load LabelMe_gist.mat;
load('LabelMe_gist.mat', 'img')
Since we had no idea from your post what kind of data this is I went ahead and downloaded it. Turns out, img is a collection of 22019 images that are of size 32x32 (RGB). This is why img is a 32 x 32 x 3 x 22019 variable. Therefore, the i-th image is accessible via imshow(img(:,:,:,i));
Here is an animation of all of them (press Ctrl+C to interrupt):
for iImage = 1:size(img,4)
figure(1);clf;
imshow(img(:,:,:,iImage));
drawnow;
end

4-d double array can't be saved into .mat matlab

I have 4-D double array named pic, with dim of ( 512, 512, 100, 29).
actually they are '.nii' images with dim of ( 512,512,100) .
each .nii image has 100 slice.
I loaded 29 nii image in matlab in pic(:,:,:,i) array and now I want to save it.
but matlab does not save it correctly.
save( 'mypic.mat' ,'pic');
matlab shows warning :
Warning: Variable 'pic' cannot be saved to a MAT-file whose version is
older than 7.3. To save this variable, use the -v7.3 switch. Skipping...
what should I do?
The data is too large to save using the default .mat file format, as the warning clearly states, you need to use the -v7.3 switch to save this size of file
save('mypic.mat', 'pic', '-v7.3')
See the documentation for more information on the various .mat file formats and their benefits and drawbacks.

Altova Mapforce- Could not find start of message error

I am using Altomava Mapforce to map and load 837 x12 formatted text files directly to Sql Server 2014. I have correctly mapped everything except I get the following errors-
Missing field F142- Application Senders code
Could not find start of message with impl.convention reference '116731H333B2'. Message will be skipped.
Missing segment GE
I have included my header and footer information below from the original source text file. Does anyone know what is going on with the mapping, or if maybe there is something wrong with the data itself? Any help would be greatly appreciated.
Header-
ISA*11* *11* *PP* *ZZ*20121143 *273041*0109*^*00501*000000000*0*T*:~GS*HC**211231153*20141121*1115*01*Y*116731H333B2~ST*837*2000001*116731H333B2~BHT*0029*00*0003000005*20141121*1115*CH
Message Data etc.......
Footer-
~SE*769*2000001~GE*1*01~IEA*1*000000000~
Your data is wrong. Here is a cleaned up version of the ISA / GS. For readability, I put a CR/LF after the segment terminator (~). Please note the ISA and GS do not indicate sender, which is going to cause all kinds of problems for auditing. See my comment above for analysis on the data per your bullet points.
ISA*11* *11* *PP*SENDER *ZZ*20121143 *273041*0109*^*00501*000000000*0*T*:~
GS*HC*SENDER*211231153*20141121*1115*01*X*005010~
ST*837*2000001*116731H333B2~
BHT*0029*00*0003000005*20141121*1115*CH
An example of the enveloping:
ISA*00* *00* *ZZ*Test1Saver *ZZ*RECEIVER *151222*1932*U*00501*000111884*0*P*:~GS*HC*Test1Saver*RECEIVER*20151222*1932*1*X*005010~ST*850*0001~
...
~SE*8*0001~GE*1*1~IEA*1*000111884~
If, 123456789 have value then map 123456789 and if having null or blank or no value then send default 123.
enter image description here

How to handle large files while reading it with python xlrd in GAE without giving DeadlineExceededError

I want to read a file having size 4 MB using python xlrd in GAE.
i am getting the file from Blobstore. Code used is given below.
book = xlrd.open_workbook(file_contents=temp_file)
sh = book.sheet_by_index(0)
for col_no in range(sh.ncols):
its gives me DeadlineExceededError.
book = xlrd.open_workbook(file_contents=file_data)
File "/base/data/home/apps/s~appid/app-version.369475363369053908/xlrd/__init__.py", line 416, in open_workbook
ragged_rows=ragged_rows,
File "/base/data/home/apps/s~appid/app-version.369475363369053908/xlrd/xlsx.py", line 756, in open_workbook_2007_xml
x12sheet.process_stream(zflo, heading)
File "/base/data/home/apps/s~appid/app-version.369475363369053908/xlrd/xlsx.py", line 520, in own_process_stream
for event, elem in ET.iterparse(stream):
DeadlineExceededError
But i am able to read files with smaller size.
Actually i need to get only first few rows(30 to 50) of the file. Is there any other method, other than adding it as a task and getting the details using channel API to get the details with out causing deadline error ?
What i can do to handle this....?
I read a file about 1000 rows excel and it works okay the library.
I leave a link that might be useful https://github.com/cjhendrix/HXLator-SpaceAppsVersion/blob/master/gae/main.py
the code I see that this crossing of columns and rows must be at lists for each row
example:
wb = xlrd.open_workbook(file_contents=inputfile.read())
sh = wb.sheet_by_index(0)
for rownum in range(sh.nrows):
val_row = sh.row_values(rownum)
#here print element of list
self.response.write(val_row[1]) #depending for number for columns
regards!!!

Resources