Read DICOM images - vtk

i am trying to read dicom images without using imageviewer and i came across VtkGdmReader.. when i am trying to execute it, its giving me an error:
code => vtkGdmReader example
error C2039: 'SetInput' : is not a member of 'vtkTexture'
error C2039: 'SetInput' : is not a member of 'vtkPolyDataMapper'
please can any one tell me why am i facing this problem, is this error related to vtk version ? if so then how can i go about it ?
please help me resolving the problem..

As said in the comments, this error is related to the VTK version. SetInput() was removed in VTK 6.
You can either work in VTK 5 or update the code. If you decide to update it, this error gets fixed by replacing SetInput() with either SetInputData() or SetInputConnection() with a few modifications. You should use SetInputConnection() if you want the filters to go through the pipeline.
As an example of fixing the errors you mentioned, you should replace the following lines in the code you provided:
VTKtexture->SetInput(ima); and
VTKplaneMapper->SetInput(VTKplane->GetOutput());
to:
VTKtexture->SetInputConnection(reader->GetOutputPort()); and
VTKplaneMapper->SetInputConnection(VTKplane->GetOutputPort());
In the second modification (VTKplaneMapper), note that we just changed GetOutput() to GetOutputPort(), while in the first one (VTKtexture) we completely changed the argument passed to SetInputConnection(). That happens because data objects (such as ima) no longer have dependency on pipeline objects (such as algorithms and executives). In this case, we give the algorithm that generated that data object as the argument - if you look for it, you can see the line vtkImageData* ima = reader->GetOutput();, you just have to replace GetOutput() by GetOutputPort() as we did in the second modification.
I recommend looking into the VTK Wiki's VTK 6 Migration pages (and guide) for more information on this error and other errors that you might run into.

Related

Trouble building R package wtih devtools when it uses RcppArmadillo

This is my first stackoverflow question, so please be kind, folks!
I have greatly enjoyed my recently-found power to build R packages using devtools. However, as soon as I try building a package that uses RcppArmadillo, my workflow of running devtools::document(), devtools::check(), and devtools::build() no longer works.
For example, I have a (hopefully pretty minimal + complete) test version of the package I'm trying to develop here: https://github.com/suztolwinskiward/fooR/. fooR contains only one functions, which is a C++ implementation of the rdist.earth function from the fields package.
Running devtools::document("fooR") spits out lots of messages (several alluding to "undefined references" to variables that do not live in my source co that are not interpretable to me, and then fails:
collect2: ld returned 1 exit status
no DLL was created
ERROR: compilation failed for package 'fooR'
* removing 'C:/Users/I53794/AppData/Local/Temp/RtmpWgC8nD/devtools_install_1ea473123086/fooR'
Error: Command failed (1)
One the other hand, when I source the C++ function that depends on RcppArmadillo, it seems to run just fine:
> Rcpp::sourceCpp('./src/rdist_earth_cpp.cpp')
> data('miami')
> data('new_orleans','katrina_path')
> rdist_earth_cpp(katrina_path,new_orleans)
[,1]
[1,] 1042.36073
[2,] 998.96793
[3,] 957.69315
[4,] 917.91486
[5,] 868.07791
[6,] 805.73485
[7,] 763.01476
[8,] 726.10133
[9,] 692.14482
[10,] 670.15133
[11,] 662.23353
[12,] 625.55592
[13,] 601.08682
[14,] 579.73940
[15,] 560.32660
[16,] 539.14192
[17,] 510.15438
[18,] 481.40037
[19,] 442.52322
[20,] 391.96619
[21,] 331.66378
[22,] 271.79088
[23,] 201.24749
[24,] 128.12647
[25,] 56.99198
[26,] 45.80297
[27,] 32.96609
[28,] 81.71237
[29,] 189.31050
[30,] 296.92104
[31,] 406.12593
[32,] 516.08458
[33,] 654.81113
[34,] 808.21670
This leads me to think there's something wrong with the way I'm trying to use RcppArmadillo in my package, but I haven't been able to figure out what. Any advice much appreciated!
P.S. I'm surprised there's no RcppArmadillo tag here....
In addition to the answers of jtilly and the comment from Dirk:
RcppArmadillo.package.skeleton() generates the correct namespace file, but after running roxygen2 via document() the namespace just contains one line
# Generated by roxygen2: do not edit by hand
and the DynLib/export directives are overwritten. To let roxygen2 automatically generate the correct namespace, add a new R file to the R-subdirectory of your package directory containing the following:
#' #useDynLib YourPackageName
#' #importFrom Rcpp evalCpp
#' #exportPattern "^[[:alpha:]]+"
NULL
The name of this file doesn't matter, but YourPackageName.r is usual for this (kind of) "main file".
When running "document()", the following namespace file is generated:
# Generated by roxygen2: do not edit by hand
exportPattern("^[[:alpha:]]+")
importFrom(Rcpp,evalCpp)
useDynLib(YourPackageName)
This is the same namespace which is generated via RcppArmadillo.package.skeleton() by RcppArmadillo 0.6.700.6.0.
Your NAMESPACE file is empty. It should contain something like this:
useDynLib(fooR)
exportPattern("^[[:alpha:]]+")
What eventually worked was to initialize a new package with RcppArmadillo.skeleton.package, move all my previous files therein, document manually, and then check and build with the GUI buttons in RStudio. This feels pretty kludgy and I really liked using roxygen2 much better for documentation-- but as a relative novice in package development with RcppAmadillo dependence, I am just happy for now to have found a way to build successfully!
'devtools::document()' compiles your code, honestly, I'm not sure why. This means that if the compilation fails, the documentation isn't completed. It seems in your case this means you don't get your NAMESPACE written.
Start as Dirk suggests, and add stuff in, but it will have to compile before the docs get done.

Unity 5.0: Sprite.Create error message "!hasError"

I came back to a Unity game that I was working on a couple of weeks ago, using version 4.6.1. After upgrading to version 5.0 and converting the project, there was an error in the following line:
Sprite.Create(plusTexture, Rect(toRightBoundry, 0, plusTexture.width, plusTexture.height), rightPos);
The image is imported as a single Sprite , 150 pixels per unit, pivoted at the center, using a bilinear filter. The import mode is compression , with a max size of 1024. Given those conditions and the fact that this piece of code was not altered since the working version and also after confirming that all values passed are valid, the following error is found at runtime:
"!hasError"
I have researched in the forums and cannot find a solution for this, mostly topics that end in the developers asking for a bug report. Is anyone familiar with how to solve this issue ?
Thanks in advance and have a nice day
it looks like an error do to unresolved merge conflicts from sprite atlas meta file of the resource file. We were getting a few funny named errors lie"aabb is not define" "!hasError" and something WIPPE. On of them was due to artist not resolving conflicts on a mesh meta file

Sphinx4 figuring out correct models

I am trying to use the Sphinx4 library for speech recognition, but I cannot seem to figure out the correct combination of acoustic model-dictionary-language model. I have tried out various combinations and I get a different error every time.
I am trying to follow the tutorial on http://cmusphinx.sourceforge.net/wiki/tutorialsphinx4. I do not have a config.xml as I would if I was using ConfigurationManager instead of Configuration, because there is no perceivable way of passing the location of the config file to the Configuration itself (ConfigMgr takes it as an argument to the constructor); and that might be my problem right there. I just do not know how to point to one, and since the tutorial says "It is possible to configure low-level components of the application through XML file although you should do that ONLY IF you understand what is going on.", I assume having a config.xml file is not compulsory.
Combining the latest dictionary (7b - obtained from Sourceforge) with the latest acoustic model (cmusphinx-en-us-5.2.tar.gz - from SF again) and the language model (cmusphinx-5.0-en-us.lm.gz - from SF again) results in NullPointerException in startRecognition. The issue is similar to the problem here: sphinx-4 NullPointerException at startRecognition, but the link given in the answer no longer works. I obtained 0.7a from SF (since that is the dict the link seems to point at), but I am getting even earlier in the execution Error loading word: ;;; when I use that one. I tried downloading latest models and dict from the Github repo, that results in java.lang.IndexOutOfBoundsException: Index: 16128, Size: 16128.
Any help is much appreciated!
You need to use latest code from github
http://github.com/cmusphinx/sphinx4
as described by tutorial
http://cmusphinx.sourceforge.net/wiki/tutorialsphinx4
Correct models (en-us) are already included, you should not replace anything. You should not configure any XML files, use samples as provided in the sources.

Issue with basic AS3 workers classes

I have followed Lee Brimelow's tutorials (part 1, part 2), but somehow my project doesn't work as expected.
Currently, publishing "src/Secondary.as" to "www/assets/swf/secondary.swf" works properly, however when trying to run "src/Main.as", an error shows up:
Exception fault: TypeError: Error #1007: Instantiation attempted on a non-constructor.
at Main/init()[/Volumes/DOCUMENTS/Tests/AS3/test-workers/src/Main.as:52]
at Main()[/Volumes/DOCUMENTS/Tests/AS3/test-workers/src/Main.as:32]
If anybody has time, you can look at my code on Github and maybe see where I screwed up? Thanks a bunch!
As your error message says: the problem raised in Line 52 in your Main.init()method. What you try to do there is to create a new instance of SecondarySWF. I would say that your embedment of Secondary class into SecondarySWF doesn't work properly, so it is not available in your init-method. You should set a breakpoint at the first line of your init-method and when the debugger reaches this point check what's in SecondarySWF. I expect that there's nothing in that variable, so what your new SecondarySWF() then means actually is new null().
Because you embed your secondary.swf with a MIME-type specified the Flex compiler ignores it because it is unable to detect the actual type of data in the loaded file. I found this post on Adobe's cookbook page that explains what you have to do in addition to adding the file using [Embed]. Hope this will fit your needs.

iPhone SQLite encryption with SQLCipher facing errors

I am trying to learn about the encryption of DB at application level using this tutorial. But I am getting an error that says
sqlcipher/sqlite3.c:11033:25: error: openssl/evp.h: No such file or directory
sqlcipher/sqlite3.c:11034:26: error: openssl/rand.h: No such file or directory
sqlite3.c:11035:26: error: openssl/hmac.h: No such file or directory
and due these there are around 93 more errors in the build process. I have strictly followed the tutorial but I am not able to get rid of those errors.
I have added the path of the source code as instructed in the tutorials but still the problem persists. The screenshot could be seen here
I had the same problem, in my case it was caused by a space in my OPENSSL_SRC path. Enclosing the value of OPENSSL_SRC in double-quotes fixed the problem.
The error messages you are seeing indicate that the compiler can't find the OpenSSL headers included in the SQLCipher code. The most likely problem is that you didn't add the OpenSSL headers to your include path when setting up your project. Perhaps you missed this step in the tutorial: "Look for the “Header Search Paths” setting and add references to $(SQLCIPHER_SRC) and $(OPENSSL_SRC). Check “recursive” on both."
As an aside, the information on that MO article is dated. In the future you can refer to this updated tutorial on the SQLCipher website: http://sqlcipher.net/documentation/ios
After long time i'm not sure whether you fixed this issue or not anyway to fix this do as follows:
In OPENSSL_SRC change destination from "/openssl-1.0.0d" to "/openssl-1.0.0d/include".
thatz it..it has to work.

Resources