Hey i am runing the following piece of code:
import nipype.interfaces.spm as spm
realign = spm.Realign()
And getting the following error:
raise IOError("This docstring was not generated by Nipype!\n") from e
OSError: This docstring was not generated by Nipype!
After debugging:
My code:
spm.Realign()
When this runs it uses matlab to run the follwing (base.py lines 217):
mlab.inputs.script = """
if isempty(which('spm')),
throw(MException('SPMCheck:NotFound','SPM not in matlab path'));
end;
spm_path = spm('dir');
[name, version] = spm('ver');
fprintf(1, 'NIPYPE path:%s|name:%s|release:%s', spm_path, name, version);
exit;
"""
try:
out = mlab.run()
I run it in Matlab and got :
>> isempty(which('spm'))
ans =
logical
0
>> [name, version] = spm('ver');
fprintf(1, 'NIPYPE path:%s|name:%s|release:%s', spm_path, name, version);
NIPYPE path:C:\Program Files\MATLAB\R2022b\toolbox\spm12\spm12|name:SPM12|release:7771
so as you can see I have result from this script, but when checking the "out" variable here (line 239):
out = sd._strip_header(out.runtime.stdout)
Stdout is "" empty string
So I think the problem is Somehow related to the answer of the script from Matlab, how to fix it ??
Thanks!
Related
I am trying to use mtimesx library on matlab 2016a, win 10 64bit, I compile this library and the following code runs in command window:
>> a=rand(2,4,2);
>> b=rand(4,5,2);
>> d=mtimesx(a,b)
d(:,:,1) =
0.5234 0.7756 0.6265 0.7531 0.6579
0.6256 0.3926 0.3557 0.7522 0.4804
d(:,:,2) =
0.6398 0.8713 0.8695 0.3040 0.6066
1.2157 1.0177 1.2590 0.5510 1.1960
but when I'm trying to run it as a script following error occurs:
Undefined function or variable 'mtimesx'.
Error in Untitled2 (line 25)
d=mtimesx(a,b);
and after that this function don't work in command window until I compile it again.
Thank you
the problem solved by making following changes in mtimesx_build.m:
1.changing mexopts = [prefdir '\mexopts.bat']; to ----> mexopts =[prefdir'\mex_C++_win64.xml'];
changing x = findstr(tline,'COMPILER=cl'); to ---> x = findstr(tline,'COMPILER="cl"');
This question is on error occurring while C code generation from MATLAB Script.
I want to convert my MATLAB script to standalone executable file. When I ran my file (Code_check.m) with 'codegen' command I got following error in target build log:
'lcclnk64' is not recognized as an internal or external command, operable program or batch file gmake: * [Code_Check_mex.mexw64] Error 1
There are other lines in target build log, commands which probably show build of c file for matlab commands (like randi,fprintf etc.)
I have checked script with %#codegen inclusion and it gives no error. While running with codegen, above mentioned error occurs. I have checked if matlab path is included in system variables path, and it is. So I have no clue how to go on.
Can somebody give some insight on how to solve this problem?
Thanks in advance
My .m script is as follows: (I apologize for long question)
% code
%#codegen
function [Output] = Code_Check
data = coder.load('EMEA_code_prep.mat');
temp_wt = find(data.Wash_cycle_data( randi(2131), : ));
fileID = fopen('Results.txt','w');
if length( find(data.Wash_cycle_data( randi(2131), : )) ) == 1;
fprintf(fileID,'%20s\n','Wash cycle type');
fprintf(fileID,'%20s\n',data.Wash_type(temp_wt,:));
else
fprintf(fileID,'%20s\n','Wash cycle type');
fprintf(fileID,'%20s\n','N/A for this trial');
end
fprintf(fileID,'%20s\n','Speen Speed');
temp_SP = data.un_SP(find(data.idx_SP( randi(2131), : )));
fprintf(fileID,'%12.8f\n',temp_SP(1) );
temp_temp_ll = find( data.Loading_level_data( randi(2131),: ) );
if length(temp_temp_ll) == 1
Output(2,3) = Loading_level(temp_temp_ll);
fprintf(fileID,'%20s\n','Loading Level');
fprintf(fileID,'%20s\n',data.Loading_level(temp_temp_ll,:));
elseif length(temp_temp_ll) == 0
%Output(2,3) = NAvar;
fprintf(fileID,'%20s\n','Loading Level');
fprintf(fileID,'%20s\n','N/A');
else
temp_temp = data.Loading_level(temp_temp_ll);
fprintf(fileID,'%20s\n','Loading Level');
fprintf(fileID,'%40s\n',temp_temp(1));
end
temp_temp_f = find( data.Fabric_type_data( randi(2131),: ) );
if length(temp_temp_f) == 1
fprintf(fileID,'%20s\n','Fabric Type');
fprintf(fileID,'%20s\n',data.Fabric_type(temp_temp_f,:));
elseif length(temp_temp_f) == 0
fprintf(fileID,'%20s\n','Fabric Type');
fprintf(fileID,'%20s\n','N/A');
else
temp_temp = data.Fabric_type(temp_temp_f);
fprintf(fileID,'%20s\n','Fabric Type');
fprintf(fileID,'%40s\n',temp_temp(1));
end
temp_temp_c = find(data.Color_data( randi(2131),: ) );
if length(temp_temp_c) == 1
fprintf(fileID,'%20s\n','Color');
fprintf(fileID,'%20s\n',data.Color(temp_temp_c,:));
elseif length(temp_temp_c) == 0
fprintf(fileID,'%20s\n','Color');
fprintf(fileID,'%20s\n','N/A');
else
temp_temp = data.Color(temp_temp_c);
fprintf(fileID,'%20s\n','Color');
fprintf(fileID,'%40s\n',temp_temp(1));
end
fprintf(fileID,'%20s\n','Wash Results');
temp_WR = data.un_Wresults(find(data.idx_Wresults( randi(131), : )));
fprintf(fileID,'%12.8f\n',temp_WR(1));
fprintf(fileID,'%20s\n','Wash Results');
temp_Spr = data.un_Spresults(find(data.idx_Wresults( randi(131), : )));
fprintf(fileID,'%12.8f\n',temp_Spr(1));
Output = data.Title;
end
and Last few lines of target build log:
14 lcclnk64 -dll -L"C:\PROGRA~1\MATLAB\R2014b\sys\lcc64\lcc64\lib64" - L"C:\PROGRA~1\MATLAB\R2014b\extern\lib\win64\microsoft" -entry LibMain "Code_Check_mex_lccstub.obj" -s -o Code_Check_mex.mexw64 Code_Check_mexutil.obj Code_Check_data.obj Code_Check_initialize.obj Code_Check_terminate.obj Code_Check.obj randi.obj fopen.obj fileManager.obj fprintf.obj _coder_Code_Check_api.obj _coder_Code_Check_mex.obj _coder_Code_Check_info.obj libmx.lib libmex.lib libmat.lib libemlrt.lib libcovrt.lib libut.lib libmwblas.lib libmwmathutil.lib Code_Check_mex_mex.def
15 'lcclnk64' is not recognized as an internal or external command,
16 operable program or batch file.
17 gmake: *** [Code_Check_mex.mexw64] Error 1
Hi I get the this error with the following script -
The script :
fid = fopen('TR2.roi', 'r');
test = []; % test variable for holding current line from text file
while isempty(test)
fline = fgetl(fid);
disp('b');
test = strmatch('; Number of',fline);
end
The error:
Error using fgets
Invalid file identifier. Use fopen to generate a valid file identifier.
Error in fgetl (line 36)
[tline,lt] = fgets(fid);
Error in test1 (line 6)
fline = fgetl(fid);
Any solutions and reason why this error? I have verified my fid it is >2.
I wrote the following function:
function [output_signal] = AddDirectivityError (bat_loc_index, butter_deg_vector, sound_matrix)
global chirp_initial_freq ;
global chirp_end_freq;
global sampling_rate;
global num_of_mics;
global sound_signal_length;
for (i=1 : num_of_mics)
normalized_co_freq = (chirp_initial_freq + chirp_end_freq)/ (1.6* sampling_rate);
A=sound_matrix ( i, : ) ;
peak_signal=max(A);
B=find(abs(A)>peak_signal/100);
if (butter_deg_vector(i)==0)
butter_deg_vector(i)=2;
end
[num, den] = butter(butter_deg_vector(i), normalized_co_freq, 'low');// HERE!!!
filtered_signal=filter(num,den, A );
output_signal(i, :)=filtered_signal;
end
This functions runs many-many times without any error. However, when I reach the line: [num, den] = butter ( butter_deg_vector(i), normalized_co_freq, 'low');
And the local variables are: i=3, butter_deg_vector(i)=1, normalized_co_freq=5.625000e-001
MATLAB prompts an error says:
??? Error using ==> buttap Expected N to be integer-valued.
"Error in ==> buttap at 15 validateattributes(n,{'numeric'},{'scalar','integer','positive'},'buttap','N');
Error in ==> butter at 70 [z,p,k] = buttap(n);"
I don't understand why this problem occurs especially in this iteration. Why does this function prompt an error especially in this case?
Try to change the code line for:
[num, den] = butter (round(butter_deg_vector(i)), normalized_co_freq, 'low');
I'm working with the following script, run_test:
#!/bin/sh
temp=$1;
cat <<EOF | matlab
[status name] = unix('echo $temp');
disp(name);
% some Matlab code
test_complete = 1;
save(name)
exit
EOF
I want to pass a name to the script, run some code then save a .mat file with the name that was passed. However, there is a curious piece of behavior:
[energon2] ~ $ ./run_test 'run1'
Warning: No display specified. You will not be able to display graphics on the screen.
< M A T L A B (R) >
Copyright 1984-2010 The MathWorks, Inc.
Version 7.12.0.635 (R2011a) 64-bit (glnxa64)
March 18, 2011
To get started, type one of these: helpwin, helpdesk, or demo.
For product information, visit www.mathworks.com.
>> >> >> >> run1
>> >> >> >> >>
[energon2] ~ $ ls *.mat
run1?.mat
There is a "?" at the end of the file name when it's saved, but not when displayed on command line. This is acceptable for my needs, but a bit irritating to not know why it's occurring. Any explanation would be appreciated.
Edits, solution:
Yuk was correct below in the underlying cause and the use of save('$temp'). I'm now using the following script
#!/bin/sh
temp=$1;
cat <<EOF | matlab
% some Matlab code
test_complete = 1;
save('$temp')
exit
EOF
Thanks for the help.
You name variable has end-of-line as the last character. When you run echo run1 in unix this command display run1 and then "hit enter". In your script all the output of echo are saved to the name variable.
You can confirm it with the following:
>> format compact
>> [status, name] = unix('echo run1')
status =
0
name =
run1
>> numel(name)
ans =
5
>> int8(name(end))
ans =
10
>> int8(sprintf('\n'))
ans =
10
Apparently this character can be a part of a file name in unix, but shell displays it as ?.
Can't you do save($temp) instead?
EDIT: See my comments below for correction and more explanation.