Author Archives: Robins

Python writes DICOM file (attributeerror: ‘filemetadataset’ object has no attribute ‘transfersyntax uid’ solution)

Write to DICOM file

import numpy as np
import matplotlib.pyplot as plt
import pydicom
import sys

def InitDicomFile():
    infometa = pydicom.dataset.Dataset()
    infometa.TransferSyntaxUID = pydicom.uid.ImplicitVRLittleEndian
    infometa.ImplementationVersionName = 'Python ' + sys.version
    infometa.MediaStorageSOPClassUID = 'CT Image Storage'
    infometa.FileMetaInformationVersion = b'\x00\x01'
    return infometa
    
filename = r'E:\34.dcm'
# ds = pydicom.dcmread(filename) # Read Tags from dicom image
ds = pydicom.read_file(filename) # Read Tags of the dicom image
info = pydicom.dataset.FileDataset({},ds) 
temp = pydicom.dcmread(filename).pixel_array # read in DICOM image and convert to numpy
img = temp.astype('uint16')
info.PixelData = img.tobytes()
infometa = InitDicomFile() # must be initialized otherwise read in will prompt an error
info = pydicom.dataset.FileDataset({},info,is_implicit_VR =True, file_meta=infometa)
# info = pydicom.dataset.FileDataset({},info) # Read without file_meta=infometa will prompt an error
info.save_as(r'M:\result.dcm')
# Verify that the newly stored DICOM can be read in
f = pydicom.dcmread(r'M:\result.dcm',force=True)
plt.imshow(f.pixel_array,'gray')
plt.show()

If there are not the following two lines, reading the stored DICOM file will prompt the following error:

infometa = InitDicomFile()
info = pydicom.dataset.FileDataset({},info,is_implicit_VR =True, file_meta=infometa)

AttributeError: ‘FileMetaDataset’ object has no attribute ‘TransferSyntaxUID’

Windows10 DOTA_devkit Error: TypeError: ‘>=‘ not supported between instances of ‘NoneType‘ and ‘str‘

1. The system configuration is: windows10 + python3.6 + anaconda3 + swig4.0.2. Swig needs to add environment variables to the system environment manually.

2. According to the official readme file, execute the command [swig – C + + – Python polyiou. I], basically no problem.

3. When executing the command [Python setup. Py build]_ The error [if self. LD] appears when “ext — inplace”_ version >= ” 2.10.90″: TypeError: ‘>=’ not supported between instances of ‘NoneType’ and ‘str’】。 In the python installation path of the virtual environment, find the file of  lib  distutils  distutils.cfg, open it and find the following content: [build] compiler = mingw32, the content of the file is correct.

4. Solution: after exploration and research, we need to configure GCC, install mingw-w64 compiler, command is [CONDA install libpython m2w64 toolchain – C msys2], and then execute the command [Python setup. Py build]_ Ext — inplace], run successfully, and you will find that the_ polyiou.cp36-win_ Amd64.pyd file.

Cannot resolve reference to bean ‘sqlSessionFactory‘ while setting bean property ‘sqlSessionFactory‘

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘collectionService’: Unsatisfied dependency expressed through field ‘collectionDao’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘collectionDao’ defined in file [E:\IdeaProjects\myMusic\target\track-stacking\WEB-INF\classes\com\hechenbo\trackstacking\dao\CollectionDao.class]: Cannot resolve reference to bean ‘sqlSessionFactory’ while setting bean property ‘sqlSessionFactory’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘sqlSessionFactory’ defined in class path resource [bean.xml]: Initialization of bean failed; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert property value of type ‘java.lang.String’ to required type ‘org.springframework.core.io.Resource[]’ for property ‘mapperLocations’; nested exception is java.lang.IllegalArgumentException: Could not resolve resource location pattern [classpath:com/hechenbo/trackstacking/dao/impl/*.xml]: class path resource [com/hechenbo/trackstacking/dao/impl/] cannot be resolved to URL because it does not exist

Error creating bean with name ‘collectionDao’ defined in file [E:\IdeaProjects\myMusic\target\track-stacking\WEB-INF\classes\com\hechenbo\trackstacking\dao\CollectionDao.class]
maven will compile and package the file will miss the xml file, when starting tomcat can not find the xml file, in all configuration files are no problem, the target folder does not contain the mapping xml file.
The xml file is not packaged by maven under the target. Add it to the <build> tag in pom.xml:

<resources>
          <resource>
              <directory>src/main/java</directory>
              <includes>
                  <include>**/*.xml</include>
              </includes>
              <filtering>true</filtering>
          </resource>
      </resources>

Then clean in Maven and restart Tomcat to display the mapping XML file in the class directory

[HBase Error]“java.lang.OutOfMemoryError: Requested array size exceeds VM limit”

Use version cdh5.4.5, hbase1.0.0

Soon after the new company arrived, the regionserver outage occurred. The exception reported is as follows:


2017-05-12 21:15:26,396 FATAL [B.defaultRpcServer.handler=123,queue=6,port=60020] regionserver.RSRpcServices: Run out of memory; RSRpcServices will abort itself immediately

java.lang.OutOfMemoryError: Requested array size exceeds VM limit

at java.nio.HeapByteBuffer.<init>(HeapByteBuffer.java:57)

at java.nio.ByteBuffer.allocate(ByteBuffer.java:331)

at org.apache.hadoop.hbase.io.ByteBufferOutputStream.checkSizeAndGrow(ByteBufferOutputStream.java:77)

at org.apache.hadoop.hbase.io.ByteBufferOutputStream.write(ByteBufferOutputStream.java:116)

at org.apache.hadoop.hbase.KeyValue.oswrite(KeyValue.java:2532)

at org.apache.hadoop.hbase.KeyValueUtil.oswrite(KeyValueUtil.java:548)

at org.apache.hadoop.hbase.codec.KeyValueCodec$KeyValueEncoder.write(KeyValueCodec.java:58)

at org.apache.hadoop.hbase.ipc.IPCUtil.buildCellBlock(IPCUtil.java:122)

at org.apache.hadoop.hbase.ipc.RpcServer$Call.setResponse(RpcServer.java:376)

at org.apache.hadoop.hbase.ipc.CallRunner.run(CallRunner.java:130)

at org.apache.hadoop.hbase.ipc.RpcExecutor.consumerLoop(RpcExecutor.java:130)

at org.apache.hadoop.hbase.ipc.RpcExecutor$1.run(RpcExecutor.java:107)

at java.lang.Thread.run(Thread.java:745)

Focus on “requested array size exceeds VM limit”

In openjdk, there is a limit that the size of the array is 2 to the power of 31 – 2. If it exceeds this size, the JVM will report an error.

In fact, this is definitely a bug in HBase IPC. In some cases, the length of the created array exceeds the limit of the JVM. Through searching, a patch is found and the problem is fixed
hbase-14598 mainly modifies the length of the array. If it exceeds this, an exception will be sent directly to the client. The direct reason is, but for an operation and maintenance company, it is more important to know which table request causes this problem?

We have a patch, hbase-16033  , More logs are provided. Finally, the following types of logs are found:


[B.defaultRpcServer.handler=90,queue=12,port=60020] ipc.RpcServer: (responseTooLarge): {"processingtimems":2822,"call":"Multi(org.apache.hadoop.hbase.protobuf.generated.ClientProtos$MultiRequest)","client":"10.120.69.147:43481","param":"region= ., for 1 actions and 1st row key=A","starttimems":1494609020832,"queuetimems":0,"class":"HRegionServer","responsesize":31697082,"method":"Multi"}

The main problem here is response size, that is, the amount of data returned at one time is too large, which leads to this problem.

In addition, in the search process, we also found that someone had a similar problem. Click Connect, which is basically the same as our type. It is worth noting that the two patches are: hbase-14946 and hbase-14978, which solve the problem of batch reading and writing exceeding the limit. The above pathc is to solve the problem of not reporting errors, and the following is the basis.

We need to find time to upgrade. I hope it will help you.

JS bug Log Uncaught TypeError: Cannot read property ‘previoustSibling‘ of null

The program code is:

 <!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>Visit the Dangdang shopping cart page node</title>
    <link type="text/css" rel="stylesheet" href="css/cartStyle.css" />
</head>
<body>

<div class="content">
    <div class="logo">
        <img src="images/dd_logo.jpg"><span onclick="close_plan();">close</span>
    </div>
    <div class="cartList" id="cartList">
        <ul>
            <li>¥<input type="text" name="price" value="21.90"></li>
            <li><input type="button" name="minus" value="-" onclick="minus(0);"><input type="text" name="amount" value="1"><input type="button" name="plus" value="+" onclick="plus(0);"></li>
            <li id="price0">¥21.90</li>
            <li><p  onclick="collection();">add</p><p onclick="del();">del</p></li>
        </ul>
        <ul>
            <li>¥<input type="text" name="price" value="24.00"></li>
            <li><input type="button" name="minus" value="-" onclick="minus(1);"><input type="text" name="amount" value="1"><input type="button" name="plus" value="+" onclick="plus(1);"></li>
            <li id="price1">¥24.00</li>
            <li><p  onclick="collection();">add</p><p onclick="del();">del</p></li>
        </ul>
        <ol>
            <li id="totalPrice">&nbsp;</li>
            <li><span onclick="accounts()">payout</span></li>
        </ol>
    </div>
    <div id="money"></div>
</div>
<script type="text/javascript" src="js/shopping.js">


</script>
<script type="text/javascript">
	function accounts(){
	     var num1=document.getElementById("cartList").firstChild.lastChild.previoustSibling.innerHTML;
		 var num2=document.getElementById("cartList").firstChild.nextSibling.lastChild.previousSibling.innerHTML;
		 var num3=document.getElementById("totalPrice").innerHTML;
		 var num4="Information about your current purchase is as follows:<br/>White Rock:White says: "+num1+"<br/>Island Bookstore: "+num2+"<br/>Total items:"+num3;
		 document.getElementById("money").innerHTML=num4;
	    }
</script>
</body>
</html>

Display error:

Uncaught TypeError: Cannot read property 'previoustSibling' of null
    at accounts (shopping.html:39)
    at HTMLSpanElement.onclick (shopping.html:29)

Error reason: unable to read space

Solution:
add element to the get node in function accounts()

The correct function code is:

function accounts(){
	     var num1=document.getElementById("cartList").firstElementChild.lastElementChild.previousElementSibling.innerHTML;
		 var num2=document.getElementById("cartList").firstElementChild.nextElementSibling.lastElementChild.previousElementSibling.innerHTML;
		 var num3=document.getElementById("totalPrice").innerHTML;
		 var num4="Information about your current purchase is as follows:<br/>White Rock:White says: "+num1+"<br/>Island Bookstore: "+num2+"<br/>Total items:"+num3;
		 document.getElementById("money").innerHTML=num4;
	    }

TypeError: r.indexOf is not a function TypeError: r.indexOf is not a function

After checking some data, it was found that the data was passed from the back end to the front end, and the front end did not handle it well, so an error was reported

Problem: because I want to load a list El table, the required data format is as follows

// Required data format for el-table's :data
[{...} ,{...} ,... ,{...}]
// The format of the data returned by the backend, I returned it directly to :data, which is obviously not correct, it should wrap a []
{...}

Based on this, the way of processing data is not right

// For example, if you deconstruct a res object from the backend, you only need [res] or [res.xx] to solve the problem
// Instance:
getUserByName(name).then(res => {
	console(res) // you can look at the format of res in the background, what you really want, and then take it out by way of .xxx
	this.userList = [res.data]
})
// I'll go back to el-table here and put :data=userlist to fix it

Kettle stores data report ora-00600 to Oracle: internal error parameters [KQD object $], [u], [0], [107], [CS], []

Check ORACLE data has a CS trigger compilation error, the problem is that the trigger state is invalid (invalid), but complie and can not pass, to drop and will report object invalid can not drop, so need to register him in sys.objerror$, in order to drop
Do you have this kind of error message ?
SQL> drop user MYUSER cascade;
drop user MYUSER cascade
*
ERROR at line 1:
ORA-00600: internal error code, arguments: [kqd-objerror$], [U], [0], [101],
[MYTRIGGER_MYCALCULATION], [], [], [], [], [], [], []
It means that one or more object is invalid. And in the error message you have the object name causing this error and then you can find the ids of instances of this object causing errors.
SQL> select object_id from dba_objects where object_name=‘MYTRIGGER_MYCALCULATION’;
OBJECT_ID

867767
840888

Now you can have logs about these objects.
SQL> select name, type , line, position, text from all_errors where name like ‘MYTRIGGER_MYCALCULATION’;
NAME TYPE LINE POSITION


TEXT
MYTRIGGER_MYCALCULATION TRIGGER 2 6
PLS-00049: bad bind variable ‘NEW.SYSVERSION’
MYTRIGGER_MYCALCULATION TRIGGER 3 4
PLS-00049: bad bind variable ‘NEW.SYSVERSION’
MYTRIGGER_MYCALCULATION TRIGGER 6 4
PLS-00049: bad bind variable ‘NEW.SYSVERSION’
Here we understand the errors are caused by compilation errors on a trigger. As we just want to drop the user object that contains this trigger, we can ignore these errors :
SQL> insert into sys.objerror$ values(867767);
insert into sys.objerror$ values(840888);
1 row created.
SQL> insert into sys.objerror$ values(840888);
insert into sys.objerror$ values(840888);insert into sys.objerror$ values(840888)
1 row created.
Then we can drop the user successfully.
SQL> drop user MYUSER cascade;
User dropped.

Uncaught TypeError: Cannot read property ‘toFixed‘ of null

Error chart:

when making the line chart , the data is obtained through Ajax , that is, clicking different values will display different charts, and then such an error occurs in the process of testing<
refer to several blogs:
ecarts.js report error cannot read property ‘ToFixed’ of null
it’s written very carefully, but it’s useless for my questions here ε=(´ο`*))) Alas

In the process of solving the above problems, the console has a warning there is a chart instance already initialized on the DOM (not in the screenshot above), and I want to know the problem to be solved, so I take a look at Baidu:
1, there is a chart instance already initialized on the DOM
2 Ecart notes – initialization and destruction
although this is not helpful for my problems, it makes me understand ecarts a little more. Let’s talk about the problems I have solved!

In fact, it’s very simple, I suddenly have an idea, try the next result is good
at the beginning, there are data (more than two), and graphics can be drawn
when you click other, the graph will not come out (at this time, there is only one data). After thinking about it, the line chart can be drawn from at least two data, ah!

Solution: there may be only one data

Deep learning model error + 1: CUDA error: device side assert triggered

Scenario:
some time ago, when running the fast RCNN model in Google’s colab, there was no problem. Later, when using featurize to rent a server to run the model, the same code kept reporting the error “CUDA error: device side assert triggered”
these two days have driven me crazy. There are many blog articles about this situation on the Internet. Most of them say that the label is out of bounds, and some of them have problems in the calculation of loss function
I can only debug step by step, and I’d better solve my own problems.

'''When running with GPU, this function reports an error “CUDA error: device-side assert triggered”'''
perm1 = torch.randperm(positive.numel(), device=positive.device)[:num_pos]
perm2 = torch.randperm(negative.numel(), device=negative.device)[:num_neg]

'''After modification, change device to cpu'''
perm1 = torch.randperm(positive.numel(), device="cpu")[:num_pos]
perm2 = torch.randperm(negative.numel(), device="cpu")[:num_neg]

Make a record, hoping to help people in the same situation.

[environment] docker: error response from daemon: OCI runtime

Background

When the compiled image is exported and loaded into another computer, the error is as follows:

//import mirror
docker import example.tar

//run the docker
docker run -it example:v20210119 /bin/bash

//error:
docker: Error response from daemon: OCI runtime create failed: container_linux.go:348: 
starting container process caused "exec: \"/bin/bash\": stat /bin/bash: no such file or directory": unknown.

For the description of this problem, there are probably two kinds of factional explanations on the Internet under Google

Left wing school

There is no/bin/bash in production, try/bin/sh, the result is still the problem

Right wing

Compatibility between Linux and docker. Then uninstall the old version and install the latest one.

The solution of the left faction is very easy to verify. After repeated verification, the problem is still unsolved. It is commonly known as the left faction.

The solution of the right faction is a bit difficult to verify, but intuition tells me that it should not be such a problem

Sure enough, I saw the right answer. After a careful look, a short description and a quick verification, the problem was solved.

this error occurs when docker runs. It is caused by different ways of saving the image. If the image is imported by using import, it should be noted that import can import the image package saved by save and the container package saved by export. However, if the image package saved by save is imported, there is no error. But this error occurs when run runs

    1. solutions
docker load < buildroot_v20210119.tar