I have an vtkImageReader2 object ... but I can not figure ut how to use
`vtkImageReader2::SetFilePrefix(...) `
and
vtkImageReader2::SetFilePattern(...)
in order to have following path:
D:\Tempx\PacientTest2\File00.dcm
D:\Tempx\PacientTest2\File01.dcm
D:\Tempx\PacientTest2\File02.dcm
...
D:\Tempx\PacientTest2\File45.dcm
Can you help me, please ?
correction
reader->SetFilePrefix("D:\\Tempx\\PacientTest2\\");
reader->SetFilePattern("%sFile%02d.dcm");
reader->SetDataExtent(0, 511, 0, 511, 0, 44);
reader->Update();
it is necessary to set the extent of the data on disk.
in this example i specify 45 images with 512x512 dimension.
tested with vtkImageReader2.
the function call GetFileNames() will not work in this case, different usage.
Related
I am trying to generate a large number of html files using rmarkdown::render in a loop, with Parameterized reports.
After generating a number of files, it stalls, and I have to restart RStudio. I can generate each individual file in itself; it is not at the same file it stalls each time when I try running the loop.
There is no error message, making it hard for me to debug.
I have tried the following, none of which helped:
Closing all other programs; reducing the memory used.
Adding knitr::knit_meta(clean = TRUE) before render
Adding clean = T inside render
Calling render with callr::r
Including rm([[data]]); gc() at the end of the .rmd file that is called by render
Any other ideas of how to try and solve this issue?
Taking This from R Markdown: The Definitive Guide Where an example is used to render multiple files. Every file would have a it's own name regarding it's param region and year.
render_report = function(region, year) {
rmarkdown::render(
"MyDocument.Rmd", params = list(
region = region,
year = year
),
output_file = paste0("Report-", region, "-", year, ".html")
)
}
While trying to handle couple attachments of types ItemAttachment and FileAttachment from an inbound email, I notice that the ItemAttachment (representing an email attachment "HELLO WORLD.eml") strips the extension .eml from the name. So I lose that info downstream in my flow.
The other types of attachments of type FileAttachment are all fine and keep their extensions. Not sure whether I am missing something or is a defect in the way the ItemAttachment is initialized. Thoughts?
Note 1: These attachments are right off the bat like: attachments = message_item.attachments
Note 2: exchangelib==3.2.0
** ATTACHMENT 1
NAME: HELLO WORLD, <== Supposed to have .eml extension
TYPE: <class 'exchangelib.attachments.ItemAttachment'>
content_type='message/rfc822',
content_id='742A502EB7681B4F8D08B03020716918#namprd10.prod.outlook.com',
size=31367,
last_modified_time=EWSDateTime(2020, 7, 20, 22, 25, 2, tzinfo=<UTC>),
is_inline=False
** ATTACHMENT 2
NAME: Daily Sync-up call.ics
TYPE: <class 'exchangelib.attachments.FileAttachment'>:
content_type='text/calendar',
content_id='AF02FF7A060C5F4BA45628DE091DF5CD#namprd10.prod.outlook.com',
size=76875,
last_modified_time=EWSDateTime(2020, 7, 20, 22, 25, 2, tzinfo=<UTC>),
is_inline=False,
is_contact_photo=False)
(some content redacted)
Item attachments in EWS are different in that they are not actually files, but references to other items in the Exchange database. So the .ics extension you probably see in e.g. Outlook is a .eml file that Outlook creates from the referenced item and offers for download. But EWS does not know about it.
In exchangelib, ItemAttachment.item is an ordinary Item, and you can use it as such. If you need the attachment, you can create a .eml file from the information contained in the item attachment, but you'll have to do that yourself or use a library to help you out.
Taking into account the accepted answer for my question, to counter the loss of .eml extension I was facing with ItemAttachment, I have adopted an explicit renaming scheme as follows:
if isinstance(a, ItemAttachment):
attach_name = a.name
regex_pat = re.compile(r'.*\.eml$') # regex for explicit .eml extension
if not regex_pat.match(a.name) and a.content_type == "message/rfc822":
attach_name += ".eml"
attachment_file = ContentFile(a.item.mime_content, name=attach_name)
An obvious gotcha is my assumption that "message/rfc822" type file has .eml as the extension and not others. But this works for my purposes in my environment as a workaround to reinstate the missing .eml extension. Leaving this approach here for compare/contrast in case anyone comes across this issue.
I want to apply KPCA on my training data before I pass it to my SVM which seems to work fine with kernlab. Afterwards I want to embed my testing input into the new space in order to make prediction with my SVM. The documentary recommends to use the predict function, which gives me an error:
dataTrain=as.xts(data)
inputTrain=dataTrain[1:settings$windowTrain,1:ncol(dataTrain)-1]
outputTrain=dataTrain[1:settings$windowTrain,ncol(dataTrain)]
kpcaa=kpca(x=inputTrain,data=NULL,kernel="rbfdot",kpar=list(sigma=0.01))
inputTrain=kpcaa#pcv
predict(object = kpcaa,newdata=inputTest)
predict(object = kpcaa,newdata=inputTest)
Error in .local(object, ...) :
unused argument (newdata = c(0.00065527734617099, -0.00281135973754587, 0.00121922641129046, -0.00356807890285626, 0.00140997344409755, 0.000281756282681123, 0.000657122764787132, -0.000469329337005497, -0.000187793427781635, 0.00046941746156115, -0.000751173744242273, 0.000281756282681123, 0.000187793427781635, -0.000469549710462758, 0.000751173744242273, 0.00140693171451645, -0.000937734502324261, -0.000469197212192185, 0.00112570368360299, -0.0014073277173825, 0.0014073277173825, -0.00112570368360299,
0.000656814473530609, -0.00253580788619168, 0.00187899341266107, -0.00310223515540553, 0.00282061112162602, 0.00121979841537989, -0.00150150178359798, 0.000469461536250826, -0.00140904630893512, -0.000188022939352273, -0.000470212074305643, -0.000282233408900545, 0.00094046842255846, -0.000188022939352273, -0.000470212074305643, -0.000470433277716786, 0.00234995643227709, 0.000938438507310124, 0.000937558666089799, 0.0034613440236777, 0.00493736156014979, 0.00046453292050951
Does anybody can help me with this one?
Thank you!
fortunately I found that there was an error in the code.
kpcaa=kpca(x=inputTrain,data=NULL,kernel="rbfdot",kpar=list(sigma=0.01))
has to be something like...
kpcaa=kpca(~.,data=inputTrain,...)
for starters, I am a complete novice with D3D11, so I apologize for my ignorance in advance.
For my games programming module I am trying to render my cubes in a wireframe format.
I have followed my lecturers' code exactly and cannot figure out what is causing the following error.
On the line "hr = _pd3dDevice->CreateRasterizerState(&wfdesc, &_wireFrame);".
I get the error that &wfDesc is of type Application::"D3D11_RASTERIZER_DESC", is not compatible with parameter of type, "const D3D11_RASTERIZER_DESC".
//Wireframe creation............................................
D3D11_RASTERIZER_DESC wfdesc;
ZeroMemory(&wfdesc, sizeof(D3D11_RASTERIZER_DESC));
wfdesc.FillMode = D3D11_FILL_WIREFRAME;
wfdesc.CullMode = D3D11_CULL_NONE;
hr = _pd3dDevice->CreateRasterizerState(&wfdesc, &_wireFrame);
_pImmediateContext->RSSetState(_wireFrame);
ID3D11DeviceContext::RSSetState;
//Wireframe creation............................................
Any ideas? My apologies for the poor asking etiquette.
I have a tidbit model that has a carrierwave uploader. Im working on attaching an inline image in an email. If I do this:
#filename = #tidbit.image.instance_variable_get('#file').filename
attachments.inline[#filename] = #tidbit.image.read
I get an inline image in my email. However, it is the full size original version.
How would I inline attach a specific version (i.e.. :thumb) of the image?
If I do:
attachments.inline[#filename] = #tidbit.image(:thumb).read
I get an argument error 1 for 0.
Late reply, but it might help googlers and I had to do something similar. The following worked:
These are the versions present on my uploader class
version :thumb do
process :resize_to_fill => [122, 70]
end
version :medium do
process :resize_to_fill => [470, 470]
end
So to get the image in a certain version I just need to do, for example:
specific_version = uploader.image.medium.read
Where medium is the version I want.
In the original question's case you need to do:
attachments.inline[#filename] = #tidbit.image.thumb.read